http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60592
Bug ID: 60592
Summary: std::array is unable to be brace/universally
initialized
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: mjbshaw at hotmail dot com
After a Q&A on StackOverflow[1], it seems there is a bug in libstdc++ (though I
suppose it could be in the gcc front end instead of libstdc++; I'm assuming
libstdc++) that prevents std::array from being brace-initialized. Consider the
following:
std::array a = {1, 2};
std::array b{a}; // error: cannot convert ‘std::array’ to
‘int’ in initialization std::array b{a};
std::array b(a); // works
b{a} is trying to initialize b by creating an initializer list with a in it
[2], as opposed to using brace/universal initialization (which would be
equivalent to b(a), which works as expected [3]).
b{a} ought to work, as far as I understand things, and this error represents a
bug.
[1]:
http://stackoverflow.com/questions/22495624/why-does-this-compile-with-visual-studio-2013-but-not-g-4-8-1
[2]: http://ideone.com/C3NJbA
[3]: http://ideone.com/zjyTr8