-
Notifications
You must be signed in to change notification settings - Fork 7
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
CWG2907 [expr.const] uninitialized glvalue of type std::nullptr_t
appears in the constant expression
#215
Comments
I think we can just modify [expr.const] p5.9 as indicated:
I believe that [conv.lval] p3 already implies that lvalue-to-rvalue conversion to a glvalue of type cv |
Yes, that's the suggested resolution.
No, [basic.indet] uniformly applies all objects with automatic or dynamic storage duration that has no initialization performed. a gvalue of |
Since we never look at the value of a |
std::nullptr_t
appears in the constant expression std::nullptr_t
appears in the constant expression
Needs cv |
Or maybe not quite. I don't know what we want to do about the |
Added cv; [conv.lval] has it, too. |
Full name of submitter (unless configured in github; will be published with the issue): Jim X
Consider this example
According to [dcl.init.general] p12
[basic.types.general] p9
Hence, [dcl.init.general] p7.3 applies here
So, the variable at
#1
has no initialization. Then, at#2
, the full-expression of the initialization comprises: lvalue-to-rvalue conversion tonp
([conv.lval]), and null pointer conversion([conv.ptr])[conv.lval] p3 says
The lvalue-to-rvalue conversion to a glvalue of type
cv std::nullptr_t
seems not to care whether the the glvalue is initialized. However, [basic.indet] saysMoreover,
np
is not usable in constant expressions according to [expr.const] p2, [expr.const] p3, and [expr.const] p4. So, the evaluation of the full-expression of the initialization at least violates[expr.const] p5
However, GCC and Clang both accept this example, only msvc rejects it.
Suggested resolution
Anyway, [conv.lval] p3.1 implies that the result of lvalue-to-rvalue conversion to any glvlaue of type
std::nullptr_t
(regardless of whether it is initialized or uninitialized), the result is always a null pointer constant.[expr.const] p5.9 and [basic.indet] p2 should have the special specification for
std::nullptr_t
.The text was updated successfully, but these errors were encountered: