https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65815
Bug ID: 65815
Summary: std::array initialization with initializer list: a =
{x,y,z} incorrectly flagged as syntax error
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: andras.aszodi at csf dot ac.at
On Page 975 of "The C++ Programming Language", 4th edition, Bjarne Stroustrup
says:
"An array can be initialized by an initializer list:
array<int,3> a1 = { 1, 2, 3 };"
and Clang (V 3.5) accepts it. However, G++ 4.9.2 thinks this is an error:
"error: array must be initialized with a brace-enclosed initializer
const std::array<double, 3> _ar0val = {1.0, -1.0, 1.0};"
The ugly fix is:
#ifdef __GNUC__
const std::array<double, 3> _ar0val{{1.0, -1.0, 1.0}};
#else
const std::array<double, 3> _ar0val = {1.0, -1.0, 1.0};
#endif
but of course it is still a bug.