No particular reason. They don't exist at the same time, and
a compiler certainly *could* allocate them at the same address.
It's valid either way as long as the code behaves correctly.
I played with it myself. With gcc -O0, I got the same result
you did. With -O1 and higher, it eliminated j and k. When I
added putchar calls to prevent that, they were both stored in the
same register.
When I changed j and k to arrays, gcc -O0 allocated them at the
same address.
And yes, block local variables have been supported for a long time.
A 1975 C reference manual allowed declarations only at the top of
a function body, but K&R1 (1978) allows declarations within any
compound statement.
--
Keith Thompson (The_Other_Keith)
Keith.S.T...@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */