This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-11-05
[Adopted at the February, 2016 meeting.]
According to 11.4.5 [class.ctor] paragraph 4 says,
A defaulted default constructor for classX is defined asdeleted if:
X is a union-like class that has avariant member with a non-trivial defaultconstructor,
...
This should make the following example ill-formed:
struct S { S(); }; union U { S s{}; } u;because the default constructor ofU is deleted. However,both clang and g++ accept this without error. Should the rule berelaxed for a union with an NSDMI?
Notes from the May, 2015 meeting:
An NSDMI is basically syntactic sugar for amem-initializer, so the presence of one should betreated as if a user-declared default constructor were present.
Proposed resolution (October, 2015):
Change 11.4.5 [class.ctor] paragraph 4 as follows:
...A defaulted default constructor for classX is defined asdeleted if:
X is a union that has a variantmember with a non-trivial default constructor and no variantmember ofX has a default memberinitializer,
X isa
union-likenon-union class that hasa variant memberM with a non-trivial defaultconstructorand no variant member of the anonymous unioncontainingM has a default member initializer,...