It's new in LLVM 7.0.0: - ``-fsanitize=implicit-integer-truncation``: Implicit conversion from integer of larger bit width to smaller bit width, if that results in data loss. That is, if the demoted value, after casting back to the original width, is not equal to the original value before the downcast. Issues caught by this sanitizer are not undefined behavior, but are often unintentional. Example: unsigned char store = 0; bool consume(unsigned int val); void test(unsigned long val) { if (consume(val)) // the value may have been silently truncated. store = store + 768; // before addition, 'store' was promoted to int. (void)consume((unsigned int)val); // OK, the truncation is explicit. }
Note that truncation is only part of recently added Implicit Conversion Sanitizer: http://releases.llvm.org/7.0.0/tools/clang/docs/ReleaseNotes.html#undefined-behavior-sanitizer-ubsan One can find a blog post about it here (mentioned in LLVM weekly): John Regehr has a short blog post on [recently added implicit integer cast sanitizers](https://blog.regehr.org/archives/1633).