Comment by ErikCorry
3 years ago
The library my dad wrote (lol) for the PDP-11 is probably full of undefined behaviour and won't work now that optimizers are using any gap in the standard to miscompile code.
3 years ago
The library my dad wrote (lol) for the PDP-11 is probably full of undefined behaviour and won't work now that optimizers are using any gap in the standard to miscompile code.
> 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.
Instead of "miscompiled" you can read "Doesn't do what it did on the PDP-11 with the compilers of the time".
Yeah, but if that definition is constantly shifting, you cannot expect it to work with existing codebases.
Well yeah — therein lies the problem with a language with pervasive undefined behavior.
The standard doesn't do that often, but it does sometimes. E.g. realloc to null which was previously defined, and is now UB :(
We 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.
What a useless and jaded assumption that code written in the past is bad.
The assumption being made here is "any useful C program relies on undefined behavior" which is pretty much true.
Yes and I'm sure it's doubly true of code that was written before the C standards were written.
That sounds like a strong take - to you have examples?
Compiling with -Wall -Werror is pretty much standard those days.
2 replies →
I certainly didn't say it was bad. Just that it went outside the boundaries of a standard that was written 25 years later.