Open xmh0511 opened 1 year ago
There're possibly some other unclear properties of unspecified objects.
GCC currently accepts this example (Godbolt link), while it seems totally unclear whether p + n
is a constant subexpression when p
points to an unspecfied object.
void fun(int& ref) {
static_assert(((42 + &ref), true));
}
Possibly related to a yet-to-report issue in P2280R4.
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[expr.const] p8 says
With this definition, when checking [expr.const] p5.9
The definition clearly says the lifetime of the unspecified object does not begin within the evaluation of
E
, instead, it includes the evaluation ofE
, hence the second bullet is not satisfied. However, the wording "unspecified object" does not clear say whether the object is usable in constant expression or not because it is unspecified. Consider this exampleThe id-expression
rf
refers to a reference that is the kind of one in [expr.const] p8, so it is treated as if it is bound to an unspecified object, so whether#1
is a well-defined constant expression or not is unspecified? Is this the intent here?Suggested Resolution
We may want to say