Skip to content

Commit 1504dca

Browse files
committed
[libcxxabi] Use __LDBL_MANT_DIG__ for configuring demangling of long doubles
This avoids needing to hardcode the mapping between architectures and their sizes of long doubles. This fixes a case in test_demangle.pass.cpp, that previously failed like this: .---command stdout------------ | Testing 29859 symbols. | _ZN5test01hIfEEvRAcvjplstT_Le4001a000000000000000E_c should be invalid but is not | Got: 0, void test0::h<float>(char (&) [(unsigned int)(sizeof (float) + 0x0.07ff98f7ep-1022L)]) `----------------------------- .---command stderr------------ | Assertion failed: !passed && "demangle did not fail", file libcxxabi/test/test_demangle.pass.cpp, line 30338 `----------------------------- This testcase is defined within // Is long double fp80? (Only x87 extended double has 64-bit mantissa) #define LDBL_FP80 (__LDBL_MANT_DIG__ == 64) ... #if !LDBL_FP80 ... #endif The case failed, by unexpectedly passing, when the demangler was capable of demangling an 80 bit long double, while the compiler actually is configured for a different size for that type.
1 parent 1c5555e commit 1504dca

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

libcxxabi/src/demangle/ItaniumDemangle.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5739,13 +5739,11 @@ struct FloatData<double>
57395739
template <>
57405740
struct FloatData<long double>
57415741
{
5742-
#if defined(__mips__) && defined(__mips_n64) || defined(__aarch64__) || \
5743-
defined(__wasm__) || defined(__riscv) || defined(__loongarch__) || \
5744-
defined(__ve__)
5742+
#if __LDBL_MANT_DIG__ == 113
57455743
static const size_t mangled_size = 32;
5746-
#elif defined(__arm__) || defined(__mips__) || defined(__hexagon__)
5744+
#elif __LDBL_MANT_DIG__ == 53
57475745
static const size_t mangled_size = 16;
5748-
#else
5746+
#else // __LDBL_MANT_DIG__ == 64
57495747
static const size_t mangled_size = 20; // May need to be adjusted to 16 or 24 on other platforms
57505748
#endif
57515749
// `-0x1.ffffffffffffffffffffffffffffp+16383` + 'L' + '\0' == 42 bytes.

0 commit comments

Comments
 (0)