Using a variable with the same name in different spaces
x
is defined at the left of =
.
so in x[x]
, [x]
refer to the global one,
whereas in x = x;
, x
hides the global x
and initializes from itself -> UB.
When you declare a new variable, its name becomes visible right here
int x =// ^- there
because it is at that point the variable is fully declared, and as such; its name means something. At this point in time any other (previously declared variable) in a surrounding scope will be hidden.
There is no scope resolution operator in C, so you may not be able to use
int x = x;
in your program.