[Bug c++/55798] New: suprious redeclaration error in for-loop
f.heckenbach@fh-soft.de
gcc-bugzilla@gcc.gnu.org
Sun Dec 23 14:15:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55798
Bug #: 55798
Summary: suprious redeclaration error in for-loop
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: f.heckenbach@fh-soft.de
Created attachment 29035
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29035
Test case
The attached example gives the error:
foo.cpp: In function 'int main()':
foo.cpp:5:11: error: redeclaration of 'int i'
foo.cpp:3:12: error: 'int i' previously declared here
I don't think that's correct. Even if the variable declared in the for-loop
goes into the scope of the loop body, the braces should open a new scope, don't
they?
FWIW, this error does not occur in C (with "-std=c99").
More information about the Gcc-bugs
mailing list