I have following code:
int X = 1;
if (int X = X)
{
    printf("%d\n", X);
    if (int X = X)
    {
       printf("%d\n", X);
    }
}
My expectation is X should be 1, 1. However, the output is:
1818935350
32767
Anyone know what's going on here? Compiled with clang-800.0.42.1
Edit: I tried the following code with a bit tweak, and now it behaves as I expected.
int X = 1;
if (int Y = X)
{
    printf("%d\n", Y);
    if (int Z = X)
    {
        printf("%d\n", Z);
    }
}
One guess is when you use variable on RHS of a declaration inside if statement, it might not refer to the variable with the same name declared at parent scope, instead it's referring to the variable that's being defined...
 
     
     
     
    