[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 11:44:00 PST 2024
================
@@ -193,7 +193,14 @@ Available checks are:
signed division overflow (``INT_MIN/-1``), but not checks for
lossy implicit conversions performed before the computation
(see ``-fsanitize=implicit-conversion``). Both of these two issues are
- handled by ``-fsanitize=implicit-conversion`` group of checks.
+ handled by ``-fsanitize=implicit-conversion`` group of checks. Note that
+ ``-fwrapv`` implicitly disables instrumentation for much of the arithmetic
+ covered by ``-fsanitize=signed-integer-overflow``.
+ - ``-fsanitize=signed-integer-wrap``: Signed Integer wraparound, where the
+ result of a signed integer computation wraps around. Behaves identically
+ to ``-fsanitize=signed-integer-overflow`` when ``-fwrapv`` is enabled.
+ Without ``-fwrapv`` or ``-fno-strict-overflow``, this sanitizer will only
+ instrument division operations.
----------------
JustinStitt wrote:
I was going off the spec, but I think I may have misinterpreted it:
`
An implementation that defines signed integer types as also being modulo need not detect integer overflow, in which case, only integer divide-by-zero need be detected.
`
>From [H.2.2 Integer Types](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf)
I initially read this as meaning we need to instrument division no matter what (just in case it's divide by zero or similar case). I can add a check for the signed overflow behavior for the division steps.
https://github.com/llvm/llvm-project/pull/80089
More information about the cfe-commits
mailing list