[libcxx-commits] [libcxx] [libcxx] [test] Clarify the condition for long double hex formatting (PR #135334)
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 24 05:17:22 PDT 2025
================
@@ -1846,11 +1846,26 @@ void test1() {
void test2() {
std::locale lc = std::locale::classic();
std::locale lg(lc, new my_numpunct);
-#if (defined(__APPLE__) || defined(TEST_HAS_GLIBC) || defined(__MINGW32__)) && defined(__x86_64__)
- // This test is failing on FreeBSD, possibly due to different representations
- // of the floating point numbers.
- // This test is failing in MSVC environments, where long double is equal to regular
- // double, and instead of "0x9.32c05a44p+27", this prints "0x1.26580b4880000p+30".
+#if (defined(__APPLE__) || defined(TEST_HAS_GLIBC) || defined(__MINGW32__)) && defined(__x86_64__) && \
+ __LDBL_MANT_DIG__ == 64
----------------
mstorsjo wrote:
i386 (both on mingw and on unix platforms) has got `__LDBL_MANT_DIG__ == 64`. I tested on mingw, and it seems like the tests within this ifdef do pass on i386 mingw too. I don't think we have CI test coverage of i386 Linux or macOS though, but it's likely that they'd behave the same. So we probably can remove the arch check and generalize it to just check for the long double size.
I guess we can move some part of the check to `test_macros.h`, but I'm not sure how you envision it with `TEST_LONG_DOUBLE_TYPE == TEST_X86_WHATEVER_IT_IS_CALLED_LONG_DOUBLE_TYPE`. We can do e.g. `TEST_LONG_DOUBLE_IS_80_BIT` which expands to 0/1 depending on this condition? But that'd just still be a check for `__LDBL_MANT_DIG__ == 64`, just abstracted with a slightly prettier name.
https://github.com/llvm/llvm-project/pull/135334
More information about the libcxx-commits
mailing list