This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/38943] New: Optimization removes trapping instruction
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jan 2009 08:55:16 -0000
- Subject: [Bug tree-optimization/38943] New: Optimization removes trapping instruction
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Following test:
--cut here--
#define _GNU_SOURCE
#include <fenv.h>
#include <signal.h>
#include <stdlib.h>
static void foo (int sig)
{
exit (0);
}
float __attribute__((noinline)) test (float x) { return 2.0f / x; };
int main()
{
signal (SIGFPE, foo);
feclearexcept (FE_ALL_EXCEPT);
feenableexcept (FE_INEXACT);
test (3.0f);
abort ();
}
--cut here--
aborts when compiled with optimizations, since the call to a procedure with a
trapping insn is removed.
$ gcc -O2 -fnon-call-exceptions -ftrapping-math -lm sf.c
$ ./a.out
Aborted
$ gcc -lm sf.c
$ ./a.out
$ [...works OK...]
A wild guess is to blame tree optimizers, since in 123t.optimized we already
have the call removed:
main ()
{
<bb 2>:
signal (8, foo);
feclearexcept (61);
feenableexcept (32);
abort ();
}
--
Summary: Optimization removes trapping instruction
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ubizjak at gmail dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38943