This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/60592] New: std::array is unable to be brace/universally initialized
- From: "mjbshaw at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 19 Mar 2014 17:06:38 +0000
- Subject: [Bug libstdc++/60592] New: std::array is unable to be brace/universally initialized
- Auto-submitted: auto-generated
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<int, 2> a = {1, 2};
std::array<int, 2> b{a}; // error: cannot convert âstd::array<int, 2u>â to
âintâ in initialization std::array<int, 2> b{a};
std::array<int, 2> 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