Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assymetry in basic.lval.11 and intro intro.object.3 #3319

Closed
dawidpilarski opened this issue Oct 23, 2019 · 1 comment
Closed

assymetry in basic.lval.11 and intro intro.object.3 #3319

dawidpilarski opened this issue Oct 23, 2019 · 1 comment

Comments

@dawidpilarski
Copy link

basic.lval.11 says, that:

If a program attempts to access the stored value of an object through a glvalue whose type is not similar ([conv.qual]) to one of the following types the behavior is undefined:

  • the dynamic type of the object,
  • a type that is the signed or unsigned type corresponding to the dynamic type of the object, or
  • a char, unsigned char, or std​::​byte type.

so we can access the value of any object with char, unsigned char and std::byte types.

However we cannot provide storage with use of char:

intro.object.3 says, that:

If a complete object is created ([expr.new]) in storage associated with another object e of type “array of N unsigned char” or of type “array of N std​::​byte” ([cstddef.syn]), that array provides storage for the created object if:

Is this asymmetry intended?
Shouldn't intro.object.3 sound like:

If a complete object is created ([expr.new]) in storage associated with another object e of type “array of N unsigned char” or type "array of N char", or of type “array of N std​::​byte” ([cstddef.syn]), that array provides storage for the created object if:

@jensmaurer
Copy link
Member

Yes, the asymmetry is intended. (The fact that the aliasing rules also allow "char" is a historical accident.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants