Test code: long double x = __builtin_infl(); int main() { int r = x == __builtin_infl(); return r ? 0 : 1; } Commands to reproduce: gcc -mlong-double-128 tc.c ./a.out && echo ok || echo fail No problem with -mlong-double-64. Cause: GCC first transforms (x == infinity) to (x > long_double_max_val). The maximum value returned by real_maxval is encoded as infinity due to rounding in encode_ibm_extended. This does not happen with the LDBL_MAX declared in system headers because one of the bits is cleared. Potential fix: --- real.c.orig 2005-09-19 12:56:24.000000000 -0400 +++ real.c 2006-04-25 21:18:32.000000000 -0400 @@ -2205,6 +2205,8 @@ real_maxval (REAL_VALUE_TYPE *r, int sig np2 = SIGNIFICAND_BITS - fmt->p * fmt->log2_b; memset (r->sig, -1, SIGSZ * sizeof (unsigned long)); clear_significand_below (r, np2); + if (REAL_MODE_FORMAT_COMPOSITE_P (mode)) + clear_significand_bit (r, SIGNIFICAND_BITS - fmt->pnan - 1); }
This works in the mainline.
Actually I am wrong in saying it worked. I usually forget to test the return value as I assume people use abort to signal a failure.
Verification using powerpc-linux-gcc-4.4.6 (--host=i686-linux): Testcase works, it seems this may be fixed. Suggest closing after soon 6 years.
Looks like this has worked correctly for some time and is being tested by at least one of the gcc.c-torture/execute/ieee/inf-*.c tests. Resolving as fixed.