Bug 46791 - [4.6 Regression] GCC fails on "for(struct { } f;;) ;", incorrectly treating it as a range-based for loop
Summary: [4.6 Regression] GCC fails on "for(struct { } f;;) ;", incorrectly treating i...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P1 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2010-12-03 20:02 UTC by Johannes Schaub
Modified: 2011-01-12 23:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-01-03 21:01:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Schaub 2010-12-03 20:02:09 UTC
The following has worked correctly before, but doesn't work anymore with GCC's range-based for-loop support enabled

void f() {
    for(struct { } f;;) ;
}

error: types may not be defined in range-based for loops

Structs in the initial part of the for loop can be useful and they are broken by that diagnostic.
Comment 1 H.J. Lu 2011-01-03 21:01:10 UTC
Works for me with revision 168409.
Comment 2 Jason Merrill 2011-01-12 23:54:07 UTC
Fixed by the patch from Rodrigo I just checked in.