[clang] [compiler-rt] [Sanitizer] add signed-integer-wrap sanitizer (PR #80089)

Justin Stitt via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 20 10:26:20 PST 2024


JustinStitt wrote:

> I believe we can move forward by reusing `-fsanitize=signed-integer-overflow`, which adds least complexity to Clang and is very reasonable.

I see a few problems with changing `-fsanitize=signed-integer-overflow`:

1) Clang no longer matches GCC's SIO functionality

2) Existing codebases (albeit, very few) may be affected by what is essentially a breaking change. 

3) The C spec language semantics all hint at `signed-integer-overflow` being a misnomer for the properties of the arithmetic we are sanitizing when `-fwrapv` is enabled. (really, `unsigned-integer-overflow` is also poorly named as unsigned arithmetic can't overflow [6.2.5.9](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf))

Should a compiler not at least put some effort into properly representing the semantics at hand?

@MaskRay, there's been lots of good review on this PR with folks more or less liking the direction of it. I'd like to find some common ground on this so we can move it forward. If you really think changing the SIO sanitizer is the way to go I'll probably close this PR and open a new one as it represents a wholly different idea.


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


More information about the cfe-commits mailing list