[Issue 199] Label causes scope to collapse into parent

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 29 04:12:55 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=199



--- Comment #13 from bearophile_hugs at eml.cc 2013-05-29 04:12:54 PDT ---
(In reply to comment #12)

> int i = 3;
> 
> void main()
> {
>   {
>     int some_condition = 1;
>     if ( some_condition )
>       goto block_end;
> 
>     /* dummy code */
>   } block_end:
> 
>   {
>     int i = 7;
>     printf("%i", i); //Local i
>   }
> 
>   printf("%i", i); //Global i (?)
> }
> --------
> C prints: "70"
> D prints: "77"
> --------


With GCC this C code gives me "73":
http://codepad.org/7uKsouJ0
http://ideone.com/GBiRCX


//import core.stdc.stdio: printf;
#include "stdio.h"

int i = 3;

int main() {
    {
        int some_condition = 1;
        if (some_condition)
            goto block_end;

        /* dummy code */
    } block_end:

    {
        int i = 7;
        printf("%i", i); //Local i
    }

    printf("%i", i); // Global i (?)
    return 0;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list