http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47453
Summary: Various non-conforming behaviors with braced-init-list
initialization
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
According to n3225, GCC is apparently not conforming to the latest specs. The
following points out some flaws.
// should be invalid (takes bullet 5 of 8.5p16, for data-member a)
// incorrectly accepted by GCC.
struct A { int a[2]; A():a({1, 2}) { } };
The spec is not clear about what behavior the following should exhibit
according to 8.5p16. As long as it's not cleared up, GCC should reconsider
whether it's desirable to accept it, it seems:
int a({0}); // spec is not clear. doesn't define this case?
The following is ill-formed, because it takes bullet 2 and then hits 8.5.3p1:
int const &b({0}); // incorrectly accepted by GCC
If both of those have different meanings with regard to validity, this is very
disgusting.
In short, the intent seems to be that a "({ ... })" initializer is only allowed
for class types, where it will hit 8.5.16p6. That's the only valid way such an
initialize can be interpreted for classes, in order not to accept the following
struct A { explicit A(int, int); };
A a({1, 2}); // this must be invalid, and GCC correctly rejects it.
In the end, I think the spec is very unclear about this, and GCC possibly
should reconsider some of its behavior here.