3 ms·
Unoptimized programs rely on this too. That's why stack buffer overflows are a thing.
by millstone 10y ago
Unoptimized programs rely on this too. That's why stack buffer overflows are a thing.
- the_why_of_y 10y agoAlso, use-after-free is UB. I have yet to hear the argument that "unoptimized C" means using a conservative garbage collector, and a free(3) that isn't a no-op is an "optimization".
- kazinator 10y agoThe issue with UB and optimizations is that sometimes programs rely on UB deliberately. The code is actually tested in every way, and it works fine for years. Then a compiler update deliberately breaks it, oops; the optimizer now assumes that it can do anything it wants if that UB occurs.
- the_why_of_y 10y agoWell, UB is, by definition, non-portable code. Nobody who knows C should be surprised that a different compiler produces different results on such code. Or even the same compiler, targeting a different architecture. Or even the same compiler, targeting the same architecture, with different flags.
- kazinator 10y agoA lot of UB is quite portable, like, oh, converting between void * and function pointers, for instance.