3 ms·
> using any gap in the standard to miscompile code For code to be miscompiled, there has to be a definition of what correctly compiling it would mean, and if t
by jolux 4y ago
> using any gap in the standard to miscompile code
For code to be miscompiled, there has to be a definition of what correctly compiling it would mean, and if there were, it would not be undefined behavior.
- ErikCorry 4y agoInstead of "miscompiled" you can read "Doesn't do what it did on the PDP-11 with the compilers of the time".
- xg15 4y agoYeah, but if that definition is constantly shifting, you cannot expect it to work with existing codebases.
- jolux 4y agoWell yeah — therein lies the problem with a language with pervasive undefined behavior.
- temac 4y agoThe standard doesn't do that often, but it does sometimes. E.g. realloc to null which was previously defined, and is now UB :(
- ErikCorry 4y agoWe are taking about code written before the standard so every bit of UB in the standard is in play here. Eg the fact that overflowing a signed int can cause the compiler to go amuck would certainly be a surprise to the person who wrote code for the PDP-11.