2 ms·
You and caf are right, the compiler can indeed remove the remove_me() call. It is permitted to assume the absence of undefined behavior, so it can 'reason' as y
by MaxBarraclough 8y ago
You and caf are right, the compiler can indeed remove the remove_me() call. It is permitted to assume the absence of undefined behavior, so it can 'reason' as you describe.
Of course, the compiler can have the code do anything at all, as it's undefined behaviour. In practice, the resulting behaviour can be deeply counterintuitive ('impossible looking' results).
> C's definition of "observable"
Indeed, which essentially changes meaning when we introduce multithreading. The perceived order of our writes isn't assured to match up to our source-code. The horror-show continues!
> And this would be a case that can really take programmers by surprise when debugging
Or worse: only in release builds. Not impossible, if you do all your debugging on unoptimised builds, but release optimised builds.