Today's “this language is broken” courtesy of @ch3root
https://godbolt.org/g/H8d0I2
-
-
BTW a nice thing in searching interesting testcases for tis-interpreter is that you are free use any UB in them:-)
-
I made the mistake, going in the other direction—tis-interpreter to GCC—of forgetting GCC doesn't have a duty to warn.
-
I agree w/
@RichFelker GCC isn't doing wrong: it assumes malloc can only return 0 for this input, so the program always runs into UB -
No. Just replace SIZE_MAX by SIZE_MAX / 4 * 3 and add -m32 and you get a genuine compiler bug.
-
well 32-bit GCC still assumes that malloc has to return 0 for this input.
-
You say it's not documented but GCC devs kindly & consistently remind anyone who reports this as a bug that GCC assumes this.
-
it's not WELL documented. There should be a prominent warning about using GCC with Glibc on 32-bit platforms. (RMS would intervene)
End of conversation
New conversation -
-
-
Maybe worth trying an aborting malloc wrapper marked with the object size and malloc attributes instead.
-
Doubt GCC is optimizing based on an assumption that the malloc return value has to be checked before use.
-
It's incorrect code, but not actually undefined UNTIL the condition it fails to handle actually happens.
-
GCC similarly only knows how to do dead store removal for malloc without OOM checks, but Clang handles them.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.