This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/31956] New: names declared in a condition may be redeclared
- From: "andrew dot stubbs at st dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 May 2007 14:58:07 -0000
- Subject: [Bug c++/31956] New: names declared in a condition may be redeclared
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The C++ standard, clauses 3.3.2 paragraph 4, and 6.4 paragraph 3, states that
names declared in the condition of `while', `if', `for' and `switch'
statements, may not be redeclared in any of the outermost controlled blocks.
This does work for `while' statements, however it does not work with `if', or
`switch' statements.
E.g. The following are compiled, but should not:
if (int foo = 0)
{
int foo = 1; // invalid
}
switch (int foo = 0)
{
default:
int foo = 1; // invalid
}
A similar example with a for statement is reported in Bug #2288
--
Summary: names declared in a condition may be redeclared
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: andrew dot stubbs at st dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31956