https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69384
Bug ID: 69384 Summary: defaulted default constructor not defined as deleted for class with a const data member which does not have a user-provided default constructor Product: gcc Version: 5.2.1 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sensorflo at gmail dot com Target Milestone: --- The standard (N4140) says in 12.1 p4: ... A defaulted default constructor for class X is defined as deleted if: ... (4.3) any non-variant non-static data member of const-qualified type (or array thereof) with no brace-or-equal-initializer does not have a user-provided default constructor, However the following compiles without error (g++ -std=c++14 -Wall -pedantic main.cpp) class A { }; class B { const A a_; }; int main() { B b{}; } If I add a member to class A I rightfully get a compile error. I assume it's an extension of gcc that it does not respect 12.1 p4.3 if the class type of the const member has no non-static members, since in this case the intention of 12.1 p4.3 is not given. Still, using -pedantic I expect gcc to 'reject all programs that use forbidden extensions'. I now have the portability problem that gcc wrongly accepts my real world program, but other compilers rightfully reject it.