Created on 2012-10-01.00:00:00 last changed 120 months ago
[Moved to DR at the September, 2013 meeting.]
Proposed resolution (August, 2013):
This issue is resolved by the resolution of issue 1460.
Proposed resolution (March, 2013) [superseded]:
Change 11.9.3 [class.base.init] paragraph 8 as follows:
[Note: this wording was reviewed during the 2013-03-25 teleconference.]In a non-delegating constructor, if a given non-static data member or base class is not designated by a mem-initializer-id (including the case where there is no mem-initializer-list because the constructor has no ctor-initializer) and the entity is not a virtual base class of an abstract class (11.7.4 [class.abstract]), then
if the entity is a non-static data member that has a brace-or-equal-initializer and, if the entity is a member of a union, no other non-static data member of that union is designated by a mem-initializer-id, the entity is initialized as specified in 9.4 [dcl.init];
...
The following example is ill-formed:
union U { int a = 0; float f; U() {} // ok, a initialized to 0 U(float f) : f(f) {} // error, constructor initializes both a and f };
because of 11.9.3 [class.base.init] paragraph 8:
An attempt to initialize more than one non-static data member of a union renders the program ill-formed.
In non-union classes, a mem-initializer takes precedence over a non-static data member initializer, per paragraph 9:
If a given non-static data member has both a brace-or-equal-initializer and a mem-initializer, the initialization specified by the mem-initializer is performed, and the non-static data member's brace-or-equal-initializer is ignored.
It would be reasonable to treat union mem-initializers in an analogous fashion.
(See also issue 1460.)
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-11-24 00:00:00 | admin | set | status: drwp -> c++14 |
2014-03-03 00:00:00 | admin | set | status: dr -> drwp |
2013-10-14 00:00:00 | admin | set | messages: + msg4693 |
2013-10-14 00:00:00 | admin | set | status: tentatively ready -> dr |
2013-09-03 00:00:00 | admin | set | messages: + msg4463 |
2013-09-03 00:00:00 | admin | set | status: drafting -> tentatively ready |
2013-05-03 00:00:00 | admin | set | messages: + msg4342 |
2012-10-01 00:00:00 | admin | create |