[libcxx-commits] [libcxx] __config: also ignore shift-out-of-bounds error with ubsan checks (PR #146688)

Jean-Michaƫl Celerier via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 2 06:11:46 PDT 2025


https://github.com/jcelerier created https://github.com/llvm/llvm-project/pull/146688

Otherwise functions such as __hash_len_16 in hash.h still trigger harmless but frustrating ubsan warnings despite being marked as _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK.

>From 5b23f2d33fe34a5dae95031968faab0752418776 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?=
 <jeanmichael.celerier+github at gmail.com>
Date: Wed, 2 Jul 2025 09:11:30 -0400
Subject: [PATCH] __config: also ignore shift-out-of-bounds error with ubsan
 checks

Otherwise functions such as __hash_len_16 in hash.h still trigger harmless but frustrating ubsan warnings despite being marked as _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK.
---
 libcxx/include/__config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__config b/libcxx/include/__config
index af8a297fdf3fd..b8331a2b4f63a 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1155,7 +1155,7 @@ typedef __char32_t char32_t;
 
 // Allow for build-time disabling of unsigned integer sanitization
 #  if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC)
-#    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
+#    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow", "shift-out-of-bounds")))
 #  else
 #    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
 #  endif



More information about the libcxx-commits mailing list