[libc-commits] [libc] [libc] Make BigInt bit_cast-able to compatible types (PR #75063)

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Mon Dec 11 08:04:05 PST 2023


gchatelet wrote:

@michaelrj-google @lntue @petrhosek 

Now even with this patch in, when we disable native support for 128 bit uint types in
https://github.com/llvm/llvm-project/blob/a9adcef45011f95ab54e7e40983da7cf9e14a08a/libc/src/__support/UInt128.h#L14-L20
and use `UInt128 = cpp::UInt<128>`, we have the following error:
```
[ RUN      ] LlvmLibcStrToLDTest.SimpleTest
external/llvm-project/libc/test/src/stdlib/strtold_test.cpp:90: FAILURE
      Expected: actual_fp.bits
      Which is: 0x7fffc000000000000000
To be equal to: expected_fp.bits
      Which is: 0x4005f600000000000000
external/llvm-project/libc/test/src/stdlib/strtold_test.cpp:92: FAILURE
      Expected: actual_fp.get_exponent()
      Which is: 16384
To be equal to: expected_fp.get_exponent()
      Which is: 6
external/llvm-project/libc/test/src/stdlib/strtold_test.cpp:93: FAILURE
      Expected: actual_fp.get_mantissa()
      Which is: 0x4000000000000000
To be equal to: expected_fp.get_mantissa()
      Which is: 0x7600000000000000
[  FAILED  ] LlvmLibcStrToLDTest.SimpleTest
```

I tried to trace it down but it feels like an issue with the `BigInt` implementation. `strtold` seems to exercise paths where `BigInt` does not quite have the same semantics as `__uint128_t`.

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


More information about the libc-commits mailing list