for loop

Timon Gehr timon.gehr at gmx.ch
Mon Jan 23 10:48:02 PST 2012


On 01/23/2012 07:06 PM, bearophile wrote:
> Ellery Newcomer:
>
>> void main(){
>>           for ({int x=0; short y=0;} x<  10; x++, y++){
>>           }
>> }
>
> I don't understand, is that a compiler bug?
> Aren't x and y in a sub-scope that ends before you use x and y?
>
> Bye,
> bearophile

It is not a bug.

ForStatement:
     for (Initialize Testopt ; Incrementopt) ScopeStatement
Initialize:
     ;
     NoScopeNonEmptyStatement

Initialize is NoScope.


More information about the Digitalmars-d-learn mailing list