This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug c++/21837] New: C++/C99 standard violation in for loop
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: gcc-bugzilla at gcc dot gnu dot org
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 31 May 2005 14:26:33 +0200
- Subject: Re: [Bug c++/21837] New: C++/C99 standard violation in for loop
- References: <20050531104619.21837.ahelm@gmx.net>
"ahelm at gmx dot net" <gcc-bugzilla@gcc.gnu.org> writes:
| C++ standard quote:
|
| 3.3.2, paragraph 4:
| Names declared in the for-init-statement, and in the condition of if, while,
| for, and switch statements are local to the if, while, for, or switch statement
| (including the controlled statement), and shall not be re-declared in a
| subsequent condition of that statement nor in the outermost block (or, for the
| if statement, any of the outermost blocks) of the controlled statement; see 6.4.
|
| However g++/gcc happily compiles:
|
| #include <stdio.h>
|
| int main(void)
| {
| for(int i=2;i<4;i++)
| {
| int j = i;
| int i;
There is duplicate of this bug in the case of C++, see PR2288.