Most of my -fsanitize=unsigned-integer-overflow
errors are bugs, but sometimes I explicitly use it as intended, which results in UBSan producing false positives.
Is there a way to turn UBSan unsigned-integer-overflow check off for a particular expression?
EDIT in response to Shafik comment, here is an example:
unsigned a = 0;
unsigned b = a - 1; // error: unsigned integer overflow
Most of the time that is a bug, sometimes it isn't. With UBSan one can find every time that happens, fix the bugs, but I haven't found a way to silence the false positives.
EDIT 2: to enable the check one needs to pass either -fsanitize=integer
(to enable all integer checks) or fsanitize=unsigned-integer-overflow
. From the comments below it seems that the check is only available in clang and not in GCC yet.