public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/27321]  New: Compare against constant infinity fails with IBM long double format
@ 2006-04-26  2:17 dvdfrdmn at users dot sf dot net
  2006-04-26  2:27 ` [Bug middle-end/27321] " pinskia at gcc dot gnu dot org
  2006-04-30  7:33 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 4+ messages in thread
From: dvdfrdmn at users dot sf dot net @ 2006-04-26  2:17 UTC (permalink / raw)
  To: gcc-bugs

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);
 }


-- 
           Summary: Compare against constant infinity fails with IBM long
                    double format
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dvdfrdmn at users dot sf dot net
GCC target triplet: powerpc-apple-darwin8


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27321


^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <bug-27321-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2012-03-02 19:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-26  2:17 [Bug middle-end/27321] New: Compare against constant infinity fails with IBM long double format dvdfrdmn at users dot sf dot net
2006-04-26  2:27 ` [Bug middle-end/27321] " pinskia at gcc dot gnu dot org
2006-04-30  7:33 ` pinskia at gcc dot gnu dot org
     [not found] <bug-27321-4@http.gcc.gnu.org/bugzilla/>
2012-03-02 19:26 ` bernhard.kaindl at thalesgroup dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).