Created on 2015-05-20.00:00:00 last changed 48 months ago
Proposed resolution (October, 2019):
Change 7.7 [expr.const] paragraph 3 as follows:
A variable is usable in constant expressions after its initializing declaration is encountered if it is a constexpr variable, or it is a constant-initialized variable of reference type or of const-qualified integral or enumeration type. An object or reference is usable in constant expressions if it is
a variable that is usable in constant expressions, or
a template parameter object (13.2 [temp.param]), or
a string literal object (5.13.5 [lex.string]), or
a temporary object of non-volatile const-qualified literal type whose lifetime is extended (6.7.7 [class.temporary]) to that of a variable that is usable in constant expressions, or
a non-mutable subobject or reference member of any of the above
, or.
a complete temporary object of non-volatile const-qualified integral or enumeration type that is initialized with a constant expression.
This resolution also resolves issue 2439.
[Adopted as a DR at the November, 2019 meeting.]
Consider an example like the following:
typedef const int CI[3]; constexpr CI &ci = CI{11, 22, 33}; static_assert(ci[1] == 22, "");
This is ill-formed because the lifetime of the array temporary did not start within the current evaluation. Perhaps we should treat all lifetime-extended temporaries of const-qualified literal type that are initialized by constant expressions as if they are constexpr objects?
History | |||
---|---|---|---|
Date | User | Action | Args |
2020-12-15 00:00:00 | admin | set | messages: + msg6446 |
2020-12-15 00:00:00 | admin | set | status: drafting -> c++20 |
2015-05-20 00:00:00 | admin | create |