Strange Scope effects

Joe Buck Joe.Buck@synopsys.COM
Tue Aug 3 16:27:00 GMT 2004


On Tue, Aug 03, 2004 at 06:23:09PM +0200, Thomas Schoebel-Theuer wrote:
> ({ // inner scope begins
>    int x = x; // parameter assignment, try to evaluate _once_
>    some code;
> })
> 
> AFAIK, in Ada the scope rules are will allow that. The x after the
> Ada := will refer to outer x, even while a new x is being defined at the
> inner scope.
> 
> In Gnu C, I get a stupid assignment of the _uninitialized_ inner
> x to itself.
> 
> I don't have access to the C99 standard. What is the required semantics?

GCC correctly implements the required semantics of C, even if it seems
stupid to you in this case.



More information about the Gcc mailing list