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

            Bug ID: 57815
           Summary: [c++11] Error spew on misspelled initializer lists
           Product: gcc
           Version: 4.7.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luto at mit dot edu

[This is fixed in trunk.  If the stable branch policy means it can't get
backported, then so be it.  I'm filing the bug because this issue is *really*
annoying.]

This erroneous code:

// Adding 'struct misspelled {int a, bc[2];};' makes this compile

void func() {
  misspelled object{1, {2, 3}};
}

Seems to throw the parser into an awful state.  The 4.7 branch says:

brace_problem.cc: In function ‘void func()’:
brace_problem.cc:4:3: error: ‘misspelled’ was not declared in this scope
brace_problem.cc:4:14: error: expected ‘;’ before ‘object’
brace_problem.cc:5:1: error: expected ‘}’ at end of input

This isn't so bad in a program this short, but in a bigger program I'm getting
multiple pages of errors scattered around the file, so finding the actual
problem is a needle-in-a-haystack problem.  If the offending code is inside a
class definition, then a bunch of the bogus errors are *before* the correct
one.

Trunk from today gets this right:

brace_problem.cc: In function ‘void func()’:
brace_problem.cc:4:3: error: ‘misspelled’ was not declared in this scope
   misspelled object{1, {2, 3}};
   ^

Reply via email to