public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65815] New: std::array initialization with initializer list: a = {x,y,z} incorrectly flagged as syntax error
@ 2015-04-20 15:16 andras.aszodi at csf dot ac.at
  2015-04-20 15:22 ` [Bug c++/65815] " mpolacek at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: andras.aszodi at csf dot ac.at @ 2015-04-20 15:16 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-06-09 15:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-20 15:16 [Bug c++/65815] New: std::array initialization with initializer list: a = {x,y,z} incorrectly flagged as syntax error andras.aszodi at csf dot ac.at
2015-04-20 15:22 ` [Bug c++/65815] " mpolacek at gcc dot gnu.org
2015-04-20 15:31 ` redi at gcc dot gnu.org
2015-04-21 10:35 ` andras.aszodi at csf dot ac.at
2015-04-21 10:46 ` daniel.kruegler at googlemail dot com
2015-05-22 16:22 ` [Bug c++/65815] brace elision doesn't work in NSDMI paolo.carlini at oracle dot com
2015-06-09 14:59 ` paolo at gcc dot gnu.org
2015-06-09 15:03 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).