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
The range of representable values of compound types #5354
Comments
No. [expr.pre] only applies to built-in types. Your example is well-defined, because you're looking at the object representation of "obj", and [basic.fundamental] p7 says "For narrow character types, each possible bit pattern of the object representation represents a distinct value." |
An object of type
It just seems to phrase something regarding the object of narrow character types. For this issue, I discussed with @languagelawyer, he may have a different opinion. |
Whatever is happening here, the intent of the wording here is certainly not to convert |
[expr.unary.op] p1 states
The expression |
This is a known issue and may be resolved by P1839. |
Right, I have read that paper before. I think this may be a temporary fix before merging that paper. As specified in that paper, the current draft just thinks the second case is UB. |
Your suggested change would go in the wrong direction, because it suggests there is an I'm not seeing a small fix proposed in this conversation that could be applied with little effort, and there is certainly nothing proposed here that might be construed as editorial. As CWG chair, I notice that P1839 addresses the area of concern, so it seems wasteful to invest time into a core issue. |
[expr.pre] p4 states
Consider these cases:
Since we just specify the range of representable values for fundamental types, as specified in subclause [basic.fundamental]. And, use a glvalue of type
char
to access the value of an object of any type is well-defined, according to [basic.lval] p11. For the first case, the value0
is clear in the range of representable values for typechar
, thus it is well-defined. However, we didn't clearly specify the range of representable values for compound types. So, it is unclear whether the value ofobj
can be in the range of representable values for typechar
.Maybe, we could clearly specify that in [basic.compound], as the following?
And improve [expr.pre] p4 to
Since we define that an object holds a value of type
T
in [basic.types.general]. So, saying an object is not in the range of representable values for its type does not make sense.The text was updated successfully, but these errors were encountered: