4 ms·
It is often instructive and useful to look at the behavior of real implementations, not just the idealized behavior given by the standard.
by mikeash 13y ago
It is often instructive and useful to look at the behavior of real implementations, not just the idealized behavior given by the standard.
- bentcorner 13y agoIndeed - sometimes you run into something and think "that shouldn't have worked", and it's useful to understand why.
- IsTom 13y agoWhen compiled with -O3 using g++ it returns 0 8. Compiler will use undefined behavior to optimize.
- mikeash 13y agoThere's a fun example with clang where you can have two pointers where: x == y But: *x != *y It involves invoking undefined behavior by using a pointer after it's been freed and arranging for a new pointer at the exact same location. Clang cached the contents of the old pointer and uses it in the comparison.