[libc-commits] [libc] [libc] Fix undefined behavior in BitsFxTest.h (PR #152347)

via libc-commits libc-commits at lists.llvm.org
Wed Aug 6 11:12:44 PDT 2025


================
@@ -63,9 +63,11 @@ class BitsFxTest : public LIBC_NAMESPACE::testing::Test {
       if constexpr (FXRep::SIGN_LEN > 0) {
         if (min <= -11 && FXRep::FRACTION_LEN >= kMinFbits) {
           // (-10.71875)_10 = (-1010.1011100)_2
-          constexpr long long kExpected = -1372;
-          EXPECT_EQ(static_cast<XType>(kExpected
-                                       << (FXRep::FRACTION_LEN - kMinFbits)),
+          constexpr long long kExpected =
+              static_cast<long long>(static_cast<unsigned long long>(-1372)
----------------
lntue wrote:

Done.

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


More information about the libc-commits mailing list