Bug 57815 - [c++11] Error spew on misspelled initializer lists
Summary: [c++11] Error spew on misspelled initializer lists
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-03 22:54 UTC by Andy Lutomirski
Modified: 2013-07-04 08:47 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.9.0
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Lutomirski 2013-07-03 22:54:50 UTC
[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}};
   ^
Comment 1 Paolo Carlini 2013-07-04 08:47:54 UTC
I think I fixed it a couple of weeks ago, with this change:

  http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00919.html

It's by no means a regression, and I have no plans to backport it. If you feel strongly, send a message to the mailing list.