uint32_t weirdness

PaulMurrayCbr:
The code is not incorrect - it does exactly what you told it to do.
The generated code code did match the source in functionality. The value of uninitialised variables with auto storage class is undefined. This is well-known, well-understood behaviour.
A

Did you read my post above from stackOverflow?

Using an unitialized variable does not automatically result in undefined behavior. It is only undefined if that variable can be also be a "register class" variable. And I am not exactly sure which types in an 8 bit processor can be register class.

Even the link you gave give a lot of exceptions to the undefined behavior rule.