[Bug c++/61122] too many initializers for NSDMI for array of unknown bound

2014-05-09 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61122

Jonathan Wakely redi at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-05-09
Summary|too many initializers   |too many initializers for
   ||NSDMI for array of unknown
   ||bound
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely redi at gcc dot gnu.org ---
I don't think you can specify an array bound from an NSDMI, but the diagnostic
is not very helpful.


[Bug c++/61122] too many initializers for NSDMI for array of unknown bound

2014-05-09 Thread f.heckenb...@fh-soft.de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61122

--- Comment #2 from Frank Heckenbach f.heckenb...@fh-soft.de ---
If it's not allowed, it should also fail at file-scope or function-scope,
shouldn't it?


[Bug c++/61122] too many initializers for NSDMI for array of unknown bound

2014-05-09 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61122

--- Comment #3 from Jonathan Wakely redi at gcc dot gnu.org ---
No. At file or function scope the initializer is definitely used, and can
provide the array bound.  On a non-static data member it is not used until the
object is constructed (and then might be ignored if there's a mem-initializer
for the member) and that's too late, the array bound for non-static data
members must be known at class definition time to know sizeof(s).

That's my understanding, and I've just checked clang agrees, with a better
diagnostic:


in.cc:10:26: error: array bound cannot be deduced from an in-class initializer
  std::vector int b1[] { { } };
 ^
in.cc:11:26: error: array bound cannot be deduced from an in-class initializer
  std::vector int b2[] { { 1, 2, 3 } };
 ^
in.cc:12:26: error: array bound cannot be deduced from an in-class initializer
  std::vector int b3[] { std::vector int () };
 ^
in.cc:13:26: error: array bound cannot be deduced from an in-class initializer
  std::vector int b4[] { std::vector int (1) };
 ^
4 errors generated.