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.

Reply via email to