[libcxx-commits] [PATCH] D123980: [libcxx] Disable long double -> int128 test with msan

Vitaly Buka via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 18 21:04:50 PDT 2022

vitalybuka created this revision.
Herald added a subscriber: pengfei.
Herald added a project: All.
vitalybuka requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

On x86 long double is 80 bit with padding, which produces
uninitialized bits in the result.
This will trigger errors with -fsanitize-memory-param-retval.

  rG LLVM Github Monorepo



Index: libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp
--- libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp
+++ libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp
@@ -21,6 +21,8 @@
 #include <cstring>
 #include <limits>
+#include "test_macros.h"
 // std::bit_cast does not preserve padding bits, so if T has padding bits,
 // the results might not memcmp cleanly.
 template<bool HasUniqueObjectRepresentations = true, typename T>
@@ -230,7 +232,8 @@
         test_roundtrip_through<double, false>(i);
-#if defined(__SIZEOF_INT128__) && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_INT128__
+#if defined(__SIZEOF_INT128__) && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_INT128__ &&                                       \
+    !TEST_HAS_FEATURE(memory_sanitizer) // Some bits are just padding.
         test_roundtrip_through<__int128_t, false>(i);
         test_roundtrip_through<__uint128_t, false>(i);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123980.423521.patch
Type: text/x-patch
Size: 1042 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220419/c4c68094/attachment.bin>

More information about the libcxx-commits mailing list