TIL about clang's -fsanitize=undefined, and immediately discovered and corrected a handful of subtle bugs lurking in one of my projects. Thanks, Zig, and thanks, Clang.
Crazy how often this catches undefined behavior. Compiling GLFW with Zig we've found like ~4 separate UB issues, one I described here[0]
Wish it could default to on with clang, but probably it'd break too many things. Really wonder how many severe issues we'd find just from turning this on by default everywhere, though.
UBSAN adds a lot of runtime overhead. Turning it on my default would mean most software built with clang (or GCC, which has also had it for years) would suddenly be dog slow, like MSVCC in debug mode. Few developers have any idea how to use their toolchain correctly, so the defaults need to be chosen wisely.
I recently started testing a project with -fsanitize=integer as well. It'll report a few potential issues that -fsanitize=undefined won't, like left shifting a 1-bit off the end.
GCC supports many of the same sanitizers as well, since they were originally developed for GCC. We use GNU's ubsan and asan in our automated test suite.