| ▲ | foltik 10 hours ago | ||||||||||||||||||||||||||||||||||
Regardless of intention, the code says this memory is uninitialized. I take issue with the compiler assuming anything about the contents of that memory; it should be a black box. | |||||||||||||||||||||||||||||||||||
| ▲ | masklinn 10 hours ago | parent [-] | ||||||||||||||||||||||||||||||||||
The compiler is the arbiter of what’s what (as long as it does not run afoul the CPU itself). The memory being uninitialised means reading it is illegal for the writer of the program. The compiler can write to it if that suits it, the program can’t see the difference without UB. In fact the compiler can also read from it, because it knows that it has in fact initialised that memory. And the compiler is not writing a C program and is thus not bound by the strictures of the C abstract machine anyway. | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||