[cfe-commits] r56060 - /cfe/trunk/lib/Parse/ParseStmt.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Thu Sep 11 12:12:17 PDT 2008
I think this is more explicit:
// C++ 3.3.2p4:
// 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).
Should I replace the "C++ 6.4p3" quote, with the above one ?
-Argiris
Neil Booth wrote:
> Argiris Kirtzidis wrote:-
>
>
>> + //
>> + // C++ 6.4p3:
>> + // A name introduced by a declaration in a condition is in scope from its
>> + // point of declaration until the end of the substatements controlled by the
>> + // condition.
>>
>
> I've read and reread the parts of the C++ standard, and I've just ended
> up confused.
>
> However I'm finding it hard to read this as saying a new scope is
> created and entered.
>
> For example,
>
> int a, b;
>
> b is "in scope" from the character 'b' but you don't enter a new scope
> when you see the 'b'.
>
> In comparison C99 is very explicit that a whole new scope is created,
> as is C++ for the controlled statements. So I don't see it for the
> outer statement in C++.
>
> This matters with, for example,
>
> void f(void)
> {
> int x;
>
> if (int x = 1)
> {
> }
> }
>
> where I read the C++ standard as requiring a redefinition of x
> error.
>
> Neil.
>
>
More information about the cfe-commits
mailing list