3 ms·
Char pointers have alignment 1 on any conforming implementation and all pointers are aligned at 0. The code will write to "address 0", assuming the compiler has
by AlotOfReading 3y ago
Char pointers have alignment 1 on any conforming implementation and all pointers are aligned at 0. The code will write to "address 0", assuming the compiler hasn't freaked out because (char*)0 is the char null pointer and thus undefined behavior to access. Note the additional caveat that address 0 may not be the first 8 bits of mapped memory (which isn't necessarily addressable).
- deleted 3y ago[deleted]
- sargstuff 3y agoThis is no-checks C. The C compiler has no run-time power. Oh wait, wasn't specified if statement was C++ or the C++ subset of C. The code can do something shifty at run time, without a power surge, to the address reference before the address is de-referenced