From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12616 invoked by alias); 16 Aug 2007 12:14:51 -0000 Received: (qmail 11068 invoked by uid 48); 16 Aug 2007 12:14:36 -0000 Date: Thu, 16 Aug 2007 12:14:00 -0000 Subject: [Bug middle-end/33088] New: [4.1/4.2/4.3 Regression] spurious exceptions with -ffloat-store X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jsm28 at gcc dot gnu dot org" 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: 2007-08/txt/msg01070.txt.bz2 Since RTH's patch , stores to the real or imaginary part of a complex variable are represented using a load of the other part and a COMPLEX_EXPR. If the variable is not yet initialized, and the load of the other part does not get optimized away, this can yield spurious floating-point exceptions (in particular, loading a signaling NaN on the x87 raises the "invalid" exception). This can happen with -ffloat-store (I don't have any proof that this is restricted to -ffloat-store, but haven't observed the problem without this option). I observed the problem originally as a failure of glibc's test-double, which is built with -ffloat-store and forms complex values by setting the real and imaginary parts separately. The following testcase reproduces it on i686-pc-linux-gnu, with trunk (-ffloat-store together with any of -O1 -O2 -O3 -Os), 4.2 branch (same options), 4.1 branch (-float-store -O1), but not for 4.0 (which predates the above mentioned patch) with any of those options. An equivalent x86-specific test could of course be written without use of . #include #include volatile int x[1024]; void __attribute__((noinline)) fill_stack (void) { volatile int y[1024]; int i; for (i = 0; i < 1024; i++) y[i] = 0x7ff00000; for (i = 0; i < 1024; i++) x[i] = y[i]; } volatile _Complex double vc; void __attribute__((noinline)) use_complex (_Complex double c) { vc = c; } double t0, t1, t2, t3; #define USE_COMPLEX(X, R, C) \ do { __real__ X = R; __imag__ X = C; use_complex (X); } while (0) void __attribute__((noinline)) use_stack (void) { _Complex double a, b, c, d; USE_COMPLEX (a, t0, t1); USE_COMPLEX (b, t1, t2); USE_COMPLEX (c, t2, t3); USE_COMPLEX (d, t3, t0); } int main (void) { fill_stack (); feclearexcept (FE_INVALID); use_stack (); if (fetestexcept (FE_INVALID)) abort (); exit (0); } -- Summary: [4.1/4.2/4.3 Regression] spurious exceptions with - ffloat-store Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jsm28 at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33088