[Bug c++/50563] New: Weird syntax acceptance rules for non-static data members initialized in place (C++0x)

ethouris at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Sep 29 08:19:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50563

             Bug #: 50563
           Summary: Weird syntax acceptance rules for non-static data
                    members initialized in place (C++0x)
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ethouris@gmail.com


In the latest version it's possible to initialize data in place.

According to the standard, non-static data members can be initialized with:

  int a = 0;

or

  int a {0};

and not with the constructor syntax:

  int a (0);

However there are probably no strict rules how the "list of variables" can be
initialized. I state that it should be normally allowed. Actually gcc accepts
the following syntax:

 int a {10}, b {20};

as well as:

 int a, b = 20;

but this one:

 int a = 10, b = 20;

ends up with the following error message:

 error: expected ‘;’ before ‘,’ token

I'm not completely sure, but it should be just strict rule: either the list of
variables syntax is not allowed when the variables are also initialized (so int
a,b=20; should fail too), or the list of variables syntax should be supported
as usual.



More information about the Gcc-bugs mailing list