[Solved] X, Y, XY why does this work in gcc? [closed]


It’s undefined behavior to use the value of an uninitialized (auto) variable that could have been declared with the register keyword (see 6.3.2.1p2 in the C standard).

int XY; could have been declared with register (you’re not taking its address anywhere) and it’s still unitialized at the right hand side of int XY = XY;, so the behavior is undefined.

If you did int XY = *&XY; the behavior would no longer be undefined, but XY would get an indeterminate value.

11

solved X, Y, XY why does this work in gcc? [closed]