Hi! I'd like to announce first version of the Undefined Behavior Sanitizer, a tool I've spent this June/July hacking on.
It is an undefined behavior detector for the C family FEs and works by creating a COMPOUND_EXPR around original expression, for slightly more information see my slides about ubsan: http://people.redhat.com/mpolacek/src/ubsan2013.pdf So far it sanitizes division-by-zeros, shifts and __builtin_unreachable calls. This is of course far from being complete; I intend to write more features during this 4.9 stage. Apart from the compiler components, ubsan needs a runtime library to function. We share that library with the LLVM implementation of ubsan. (We do the same for tsan/asan.) The DejaGNU test harness is a part of this patch and passes with both -m64 and -m32 (at least on my machine ;), haven't really tried e.g. PPC or S390, where it could be interesting to try -m31). I'm not aware of any major issues right now (doesn't mean there aren't any...), but e.g. how well this works with constexpr is still subject to discover. Furthermore, this patch tweaks parsing of -fsanitize= option, now it is possible to write e.g. -fsanitize=undefined,address -fno-sanitize=shifts . For this, the gcc spec language has been tweaked slightly. The ChangeLog.ubsan files are meant to disappear at commit time, as theirs content will be updated and prepended to the normal ChangeLog files. I'm attaching the .tar.bz2 archive, which contains the whole patch together with the ubsan library (located in libsanitizer/). Everything's also available on my git only branch ubsan. I'll also send a patch that contains everything but libsanitizer/ changes to make the reviewing hopefully more convenient. After the merge, we shouldn't forget to update the http://gcc.gnu.org/gcc-4.9/changes.html page. Here I'd like to thank Jakub, without him there would be no ubsan at all. Regtested/bootstrapped on x86_64-linux. Comments? Marek
U.tar.bz2
Description: BZip2 compressed data