Hacker News new | past | comments | ask | show | jobs | submit login

Clang has a mode (UBsan) that flags and optionally aborts if you execute UB. It runs several times slower because it has to check lots of things, but it might make sense for some programs.



UBSan is not exhaustive. There are large and important cases of UB it cannot detect. There are also cases where the compiler simply won't insert the proper checks even for detectable issues. None of the sanitizers are broadly intended for production use either, though UBSan offers a specific mode you can select (fsanitize-minimal-runtime) that's appropriate for some production uses.


GCC can also use UBSan (and ASan) [1], and furthermore, it shouldn't be "several times slower" (are you thinking of Valgrind?). Clang itself describes the checks as "small runtime cost" [2] and there's a minimal variant as well.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.h... [2]: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: