public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/38943]  New: Optimization removes trapping instruction
@ 2009-01-23  8:55 ubizjak at gmail dot com
  2009-01-23  9:21 ` [Bug tree-optimization/38943] " rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: ubizjak at gmail dot com @ 2009-01-23  8:55 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug tree-optimization/38943] Optimization removes trapping instruction
  2009-01-23  8:55 [Bug tree-optimization/38943] New: Optimization removes trapping instruction ubizjak at gmail dot com
@ 2009-01-23  9:21 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-01-23  9:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-01-23 09:21 -------
FENV access is not implemented.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|                            |


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-23  9:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-23  8:55 [Bug tree-optimization/38943] New: Optimization removes trapping instruction ubizjak at gmail dot com
2009-01-23  9:21 ` [Bug tree-optimization/38943] " rguenth at gcc dot gnu dot org

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).