Created on 2016-05-26.00:00:00 last changed 83 months ago
Proposed resolution (February, 2017):
Add the following as a new bullet following 7.7 [expr.const] bullet 2.8
A conditional-expression e is a core constant expression unless the evaluation of e , following the rules of the abstract machine (6.9.1 [intro.execution]), would evaluate one of the following expressions:
...
an lvalue-to-rvalue conversion (7.3.2 [conv.lval]) that is applied to a glvalue that refers to a non-active member of a union or a subobject thereof;
an invocation of an implicitly-defined copy/move constructor or copy/move assignment operator for a union whose active member (if any) is mutable, unless the lifetime of the union object began within the evaluation of e;
...
Delete bullet 3.2 in 9.2.6 [dcl.constexpr]:
for a defaulted copy/move assignment, the class of which it
is a member shall not have a mutable subobject that is a variant
member;
Delete bullet 4.2 in 9.2.6 [dcl.constexpr]:
for a defaulted copy/move constructor, the class shall not
have a mutable subobject that is a variant member;
[Adopted at the February/March, 2017 meeting.]
Issue 2004 concerns this example:
union U { int a; mutable int b; }; constexpr U u1 = {1}; int k = (u1.b = 2); constexpr U u2 = u1;
Clearly this must be ill-formed. But issue 2004 goes too far by making the copy and move operations of U non-constexpr. This breaks reasonable code such as:
constexpr int f() { U u = {1}; U v = u; return v.a; }
History | |||
---|---|---|---|
Date | User | Action | Args |
2018-02-27 00:00:00 | admin | set | messages: + msg6160 |
2018-02-27 00:00:00 | admin | set | status: open -> c++17 |
2016-05-26 00:00:00 | admin | create |