https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69127
Bug ID: 69127 Summary: inconsistent handling of initializers of zero-length array members Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- G++ accepts zero-length array members as an extension, however as the test case below shows, it doesn't handle their initialization consistently. In the test case, since they are all equivalent, the constructors of all of B1, B2, and B3 should either all be rejected or all accepted. As a data point, Clang rejects all three. I would suggest to follow suit. $ cat u.c && ~/bin/gcc-5.1.0/bin/g++ -Wall -Wextra -std=c++11 u.c struct A { A (int); }; struct B1 { A a[0]; } b1; struct B2 { B2 (): a () { } // accepted A a[0]; } b2; struct B3 { B3 () = default; A a[0]; } b3; u.c:5:3: error: use of deleted function ‘B1::B1()’ } b1; ^ u.c:3:8: note: ‘B1::B1()’ is implicitly deleted because the default definition would be ill-formed: struct B1 { ^ u.c:3:8: error: no matching function for call to ‘A::A()’ u.c:1:12: note: candidate: A::A(int) struct A { A (int); }; ^ u.c:1:12: note: candidate expects 1 argument, 0 provided u.c:1:8: note: candidate: constexpr A::A(const A&) struct A { A (int); }; ^ u.c:1:8: note: candidate expects 1 argument, 0 provided u.c:1:8: note: candidate: constexpr A::A(A&&) u.c:1:8: note: candidate expects 1 argument, 0 provided u.c:15:3: error: use of deleted function ‘B3::B3()’ } b3; ^ u.c:13:3: note: ‘B3::B3()’ is implicitly deleted because the default definition would be ill-formed: B3 () = default; ^ u.c:13:3: error: no matching function for call to ‘A::A()’ u.c:1:12: note: candidate: A::A(int) struct A { A (int); }; ^ u.c:1:12: note: candidate expects 1 argument, 0 provided u.c:1:8: note: candidate: constexpr A::A(const A&) struct A { A (int); }; ^ u.c:1:8: note: candidate expects 1 argument, 0 provided u.c:1:8: note: candidate: constexpr A::A(A&&) u.c:1:8: note: candidate expects 1 argument, 0 provided