[libc-commits] [libc] [libc][msan] Fix "non-constexpr function '__msan_unpoison' cannot be used in a constant expression" (PR #88719)

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Tue Apr 16 05:09:43 PDT 2024


================
@@ -47,14 +47,21 @@
 // Functions to unpoison memory
 //-----------------------------------------------------------------------------
 
-#if defined(LIBC_HAVE_MEMORY_SANITIZER) && __has_builtin(__builtin_constant_p)
-// Only perform MSAN unpoison in non-constexpr context.
+#if defined(LIBC_HAVE_MEMORY_SANITIZER)
+// Only perform MSAN unpoison in non-constexpr context and silence
+// '-Wconstant-evaluated' when MSAN_UNPOISON is called from manifestly constant
+// contexts.
 #include <sanitizer/msan_interface.h>
 #define MSAN_UNPOISON(addr, size)                                              \
   do {                                                                         \
-    if (!__builtin_constant_p(*addr)) {                                        \
+    _Pragma("GCC diagnostic push \"-Wconstant-evaluated\"");                   \
+    _Pragma("GCC diagnostic ignored \"-Wconstant-evaluated\"");                \
----------------
gchatelet wrote:

Nope indeed, this is unneeded.

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


More information about the libc-commits mailing list