This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/60592] New: std::array is unable to be brace/universally initialized


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]