Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on /story/45422717. Parent comment
In fact we can make the example even shorter: https://godbolt.org/z/8fv4GKMse
And here's one with a "time travelling" removal of a branch because of UB: https://godbolt.org/z/PjYzqKxs4
Remove the memcpy, and it adds the comparison back in: https://godbolt.org/z/r1GTvGnnf
This one is fun too: Explicitly crash on null pointer: https://godbolt.org/z/sGzhK7zM4
As this comment (https://news.ycombinator.com/item?id=45442103) says, it looks like we may have just been talking past each other.
When I said "If you check for null pointer before you dereference, then no the compiler cannot elide the check." I meant like:
if (ptr != NULL) { *ptr = 123; }
if (ptr != NULL) { [… something else …] } *ptr = 123;
There are no comments on this comment yet.
In fact we can make the example even shorter: https://godbolt.org/z/8fv4GKMse
And here's one with a "time travelling" removal of a branch because of UB: https://godbolt.org/z/PjYzqKxs4
Remove the memcpy, and it adds the comparison back in: https://godbolt.org/z/r1GTvGnnf
This one is fun too: Explicitly crash on null pointer: https://godbolt.org/z/sGzhK7zM4
As this comment (https://news.ycombinator.com/item?id=45442103) says, it looks like we may have just been talking past each other.
When I said "If you check for null pointer before you dereference, then no the compiler cannot elide the check." I meant like:
Which is obviously safe and the compiler cannot remove the check. Not: The latter is UB, and UB is allowed to time travel.