From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65179 invoked by alias); 14 Mar 2015 17:14:09 -0000 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 Received: (qmail 65122 invoked by uid 48); 14 Mar 2015 17:14:06 -0000 From: "p.vanhoof at oma dot be" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/65425] New: code optimization leads to spurious FP exception Date: Sat, 14 Mar 2015 17:14: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-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: p.vanhoof at oma dot be X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg01481.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65425 Bug ID: 65425 Summary: code optimization leads to spurious FP exception Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: p.vanhoof at oma dot be Created attachment 35035 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35035&action=edit program that triggers the bug Compile the attached test case with gcc -O3 -ftrapping-math -fno-math-errno bug.c -lm This produces no output. Running the executable will result in a spurious FP exception. This happens with all gcc versions I tested since 4.7.0. Versions 4.6.4 and earlier work correctly, so this is a regression. It looks like the code is being optimized with the implicit assumption that FP exceptions are not trapped. However, using the -ftrapping-math flag should prevent such optimizations (and should be the default as well). % gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/gcc492/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc492/configure --prefix=/usr/local/gcc492 --enable-languages=c,c++,fortran Thread model: posix gcc version 4.9.2 (GCC)