The original C committee wrote, as part of its guiding principle to “Keep the spirit of C”, that “To help ensure that no code explosion occurs for what appears to be a very simple operation, many operations are defined to be how the target machine’s hardware does it rather than by a general abstract rule.”¹ That is, if you write `a = b + c` you expect the compiler to generate an `add a, b, c` instruction, and if that happens to trap and burn your house down, well, that's not C's problem.
I'm convinced that the original UB rule was intended to capture this, and the wording was an error later seized by compiler developers. As evidence, consider Dennis Ritchie's rejection of `noalias` as “a license for the compiler to undertake aggressive optimizations that are completely legal by the committee's rules, but make hash of apparently safe programs”². If anyone at the time had realized that this is what the definition of UB implied, it would have been called out and rejected as well.
> if you write `a = b + c` you expect the compiler to generate an `add a, b, c`
this could be violated even by simple optimizing compilers that do constant propagation or strength reductions.
Again, if you do not want optimizations -O0 is always available.
The statement, in context, is a simple illustration of the principle that C operator semantics were defined by the target hardware. Not a treatise on compiler construction.
It would be nice if optimizing compilers' -O0 weren't completely insane on the assumption that the insanity would get optimized out.
Nowhere does anyone guarantee that you won't be hit with nasal demons if you use -O0
Well, it is hard to guarantee anything about a bit of code with no defined semantics, you'll have to settle for what O0 gives you.
Hmmm...
"To help ensure that no code explosion occurs for what appears to be a very simple operation"
How does constant propagation cause code explosion?
I think expecting the compiler to generate code that makes 'a' hold the sum of 'b' and 'c', assuming there is code that "observes" the value in some way, is a more useful model.