3 ms·
The horror stories about compilers optimizing away code based on statically detected UB are frightening, and largely the compiler vendors seem to be to blame.
by jstimpfle 7y ago
The horror stories about compilers optimizing away code based on statically detected UB are frightening, and largely the compiler vendors seem to be to blame.
But there's also a good amount of FUD in the play. Personally I'm not sure I've ever encountered any problems with UB. Sure, I've had my share of NULL dereferences, but in practice they manifest as segfaults, which are akin to exceptions in other languages.
And while the list of UBs in C can still be considered a weakness, the fact that compilers usually don't issue a warning is not, because UB is a runtime thing, so compilers cannot do anything about it (in general, and typically). That is something that seems to be not well understood. And it was the point I was making.