3 ms·
> > C has undefined behaviour in the first place (unlike, say, Java) is to maximally enable compiler optimisation. > My understanding is that C has undefined b
by oddity 8y ago
> > C has undefined behaviour in the first place (unlike, say, Java) is to maximally enable compiler optimisation.
> My understanding is that C has undefined behaviour where there is no universally sensible implementation across all architectures.
These are two ways of looking at the same thing. A naive translation of C statements to what seems like the most straightforward way to do them on some target architecture is an optimization over emulating some other architecture’s behavior. Consider the problem of translating one arch’s assembly to another’s. Essentially, C needs to be defined at a certain level of abstraction for all of this to work, but it also happens that detecting holes in this abstraction is undecideable.
- jstimpfle 8y agoThat's OT. There isn't any confusion what "optimization" means here.
- MaxBarraclough 8y agoPerhaps I'm being pedantic, but that's not really what 'optimisation' means. Optimisation refers to code transformations which result in output code which has better performance (whether in terms of space or time). Changing the definition of the source language, isn't optimisation. Whether the source language can cleanly be mapped to the target machine, may be significant to performance, but it's not optimisation.
- mpweiher 8y ago> in output code which has better performance Without changing the output. That's the crucial part of the contract current compilers are breaking. And then try to lawyer it away by claiming that the original was undefined anyway so they can do whatever the hell they want.