Consider this code: void f1() { for (int i = 0;;) int i; }
void f2() { for (int i = 0;;) { int i; } } void f3() { for (int i = 0;;) { { int i; } } } Only f3() should compile, yet f1() and f2() compile too. While f1() seems wrong without giving it much thought, f2() is wrong as well, due to 6.4/3 (which seems a bit at odds with 6.5.3) I tested 4.3.3 and 4.4.0 This issue was found during a port to MSVC, and was covered here: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=489105 -- Summary: variables with the same name as a "for" variable should be invalid Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ciobi at inbox dot com GCC build triplet: x86_64-suse-linux GCC host triplet: x86_64-suse-linux GCC target triplet: x86_64-suse-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41427