http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52915
Bug #: 52915 Summary: [C++11] Deleted default-constructor of anonymous unions not honored Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: daniel.krueg...@googlemail.com gcc 4.8.0 20120318 (experimental) in C++11 mode accepts the following code: //--- struct S { int val; S(int v) : val(v) {} }; void f() { union { S a; }; } //--- This seems to violate to what the standard says. According to 9.5 p5: "A union of the form union { member-specification } ; is called an anonymous union; it defines an unnamed object of unnamed type." combined with 12.1 p5 b6: "A defaulted default constructor for class X is defined as deleted if: [..] — any [..] non-static data member with no brace-or-equal-initializer, has class type M [..] and [..] M has no default constructor [..]" The last item has the effect that the anonymous union defined in f() is a union-like class that has a deleted default constructor, but the definition in f() also defines an unnamed object of that type which is default-initialized. It seems that gcc does not respect the last part of the semantics of this declaration.