logoalt Hacker News

IshKebabyesterday at 11:03 AM1 replyview on HN

No it doesn't. Compilers are only required to emit the read for volatile types. If the type is non-volatile, misaligned, and can be optimised out then it would be perfectly fine to omit it (that would be the "succeed" option).


Replies

1718627440yesterday at 11:34 AM

If a trap is observable behaviour, then the compiler either needs to add code, that checks for the condition and then traps explicitly or it needs to actually perform the read. Currently it can be optimized out, because it is UB.

show 2 replies