[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:47:28 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:

> Actually it's very inconsistent that the sanitizer is less strict without `-fwrapv`, when for `signed-integer-overflow` we have an opposite.

Yes, this proposed "wrap" wrap sanitize is less strict when nothing is defined as wrapping (i.e: missing `-fwrapv`). Should this not be the case?


In the same way, `signed-integer-overflow` is more strict without `-fwrapv` as things are  overflowing and not wrapping. 

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


More information about the cfe-commits mailing list