If you pass clang -fwrapv then this causes -fsanitize=undefined to no longer complain about signed integer overflows from addition. However the sanitizer will still complain about left shifts of negative values. -fwrapv should apply also to shifts. In addition -fwrapv in clang should suppress -Wshift-negative-value. (The GCC manuals only mention -fwrapv to affect add/sub/mult because GCC currently _never_ treats signed left shifts as having undefined behavior. GCC documentation however says very clearly, under -fstrict-overflow, that "Using '-fwrapv' means that integer signed overflow is fully defined: it wraps").
These changes have now been committed to GCC. In addition, GCC is now promising not to use the latitude offered by the standard in treating overflowing << and << of a negative number as undefined in C99 or later. LLVM is not yet documenting any kind of implementation-defined behavior (bug 11272).
GCC doc patches: https://gcc.gnu.org/ml/gcc-patches/2015-11/msg03055.html https://gcc.gnu.org/ml/gcc-patches/2015-12/msg01034.html
Fix up for review at https://reviews.llvm.org/D23498
Fix committed in r278786. Nominated for inclusion in 3.9.