Unlike register variables, auto variables have the address. I don't think compiler has the right to replace real address of variable with something meaningless. I don't mind allocating auto variables in registers, I don't mind if stk isn't allocated on stack, but compare expression has to compare something meaningful, not random data because of too smart optimization.
Even with volatile, it is still rubbish, because C doesn't require stack at all. Compiler can allocate stk not in the stack space, like it is done in C compilers for PIC (PIC16, PIC18).
uint32_t doesn't help, because there are at least 3 16bits CPU registers, more than enough for uint32_t. Also optimizer may be too smart and ignore not used high order bits.