[clang] Sanitizer: Support -fwrapv with -fsanitize=signed-integer-overflow (PR #82432)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 16 02:03:37 PDT 2024


nikic wrote:

> > Shouldn't plain `-fsanitize=undefined` disable this sanitizer by default (requiring explicit opt-in)? In `-fwrapv` mode this is not undefined behavior, so `-fsanitize=undefined` should not complain about it.
> 
> I was on the fence whether `-fsanitize=undefined` should expand to signed-integer-overflow: [#80089 (comment)](https://github.com/llvm/llvm-project/pull/80089#issuecomment-1945202620)
> 
> Perhaps you have run into some convenience issues? #85501 for the signed-integer-overflow suppresion.

I don't use `-fwrapv` myself, so this is more a philosophical consideration. It seems wrong to me for `-fsanitize=undefined` to report something as undefined behavior which is not undefined behavior in the used language dialect. `-fsanitize=undefined` already has a lot of checks that are conditioned on the used language dialect, so excluding the signed overflow case in particular from that general approach it is a bit odd.

Thanks for putting up the patch!

https://github.com/llvm/llvm-project/pull/82432


More information about the cfe-commits mailing list