From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19979 invoked by alias); 8 Apr 2012 21:45:09 -0000 Received: (qmail 19971 invoked by uid 22791); 8 Apr 2012 21:45:07 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 08 Apr 2012 21:44:54 +0000 From: "jsm28 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/52907] New: Underflowing floating point expressions wrongly folded to zero Date: Sun, 08 Apr 2012 21:45:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jsm28 at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg00525.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52907 Bug #: 52907 Summary: Underflowing floating point expressions wrongly folded to zero Classification: Unclassified Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: jsm28@gcc.gnu.org fold-const.c:const_binop avoids folding overflowing floating-point operations on constant operands to constants if flag_trapping_math: /* Don't constant fold this floating point operation if the result has overflowed and flag_trapping_math. */ if (flag_trapping_math && MODE_HAS_INFINITIES (mode) && REAL_VALUE_ISINF (result) && !REAL_VALUE_ISINF (d1) && !REAL_VALUE_ISINF (d2)) return NULL_TREE; However, there is no such check for underflow. This has the effect of miscompiling various code in glibc's libm that expects operations on constant values to be usable to produce an overflow or underflow exception when required. In particular, this appears to cause . Testcase, tested x86 and x86_64 (-O2 -ftrapping-math, wrongly compiled to return 0 rather than doing the given computation): static const double a = 1e-300; double f (void) { return a * a; }