public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/9783] New: fetestexcept(FE_INEXACT) does not return expected result when inexact trapping is disabled
@ 2009-01-24 15:38 abramo dot bagnara at gmail dot com
  2010-05-04 17:16 ` [Bug math/9783] " mattst88 at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: abramo dot bagnara at gmail dot com @ 2009-01-24 15:38 UTC (permalink / raw)
  To: glibc-bugs

Running the program below, it seems that if feenableexcept(FE_INEXACT) is not
called fetestexcept(FE_INEXACT) doesn't work as expected (and as C99 standard
provides).

Please note that according to documentation GNU extension
feenableexcept/fedisablexcept does not enable/disable inexact detection, but
does enable/disable inexact *trapping* via SIGFPE signal.

Also please ignore the incorrect return from the overly simplified signal
handler (it would generate an infinite loop on some architectures).

The bug was previously believed a gcc one
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37581),
but recently we got new info that shows this is not true.

$ cat sf2.c 
#define _GNU_SOURCE
#include <fenv.h>
#include <signal.h>
#include <stdio.h>

static void foo (int sig)
{
  printf("inexact\n");
}


float __attribute__((noinline)) test (float x) {
        printf("%f / %f\n", 2.0f, x);
        return 2.0f / x;
}

void t()
{
  volatile float x;
  feclearexcept (FE_ALL_EXCEPT);
  x = test (3.0f);
  printf("fetestexcept(FE_INEXACT) = %d\n", fetestexcept(FE_INEXACT));
  feclearexcept (FE_ALL_EXCEPT);
  x = test (2.0f);
  printf("fetestexcept(FE_INEXACT) = %d\n", fetestexcept(FE_INEXACT));
}

int main() {
  printf("\nWith FE_INEXACT SIGFPE disabled\n");
  t();

  printf("\nWith FE_INEXACT SIGFPE enabled\n");
  signal (SIGFPE, foo);
  feenableexcept (FE_INEXACT);
  t();
}
$ gcc -O2 -lm -mieee-with-inexact sf2.c
$ ./a.out

With FE_INEXACT SIGFPE disabled
2.000000 / 3.000000
fetestexcept(FE_INEXACT) = 0
2.000000 / 2.000000
fetestexcept(FE_INEXACT) = 0

With FE_INEXACT SIGFPE enabled
2.000000 / 3.000000
inexact
fetestexcept(FE_INEXACT) = 2097152
2.000000 / 2.000000
fetestexcept(FE_INEXACT) = 0
$

-- 
           Summary: fetestexcept(FE_INEXACT) does not return expected result
                    when inexact trapping is disabled
           Product: glibc
           Version: 2.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: aj at suse dot de
        ReportedBy: abramo dot bagnara at gmail dot com
                CC: bagnara at cs dot unipr dot it,glibc-bugs at sources dot
                    redhat dot com
 GCC build triplet: alphaev56-unknown-linux-gnu
  GCC host triplet: alphaev56-unknown-linux-gnu
GCC target triplet: alphaev56-unknown-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=9783

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug math/9783] fetestexcept(FE_INEXACT) does not return expected result when inexact trapping is disabled
  2009-01-24 15:38 [Bug math/9783] New: fetestexcept(FE_INEXACT) does not return expected result when inexact trapping is disabled abramo dot bagnara at gmail dot com
@ 2010-05-04 17:16 ` mattst88 at gmail dot com
  2010-05-04 17:17 ` mattst88 at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: mattst88 at gmail dot com @ 2010-05-04 17:16 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From mattst88 at gmail dot com  2010-05-04 17:16 -------
Can you still reproduce this? I just ran your test program on my UP1500 and and
could not reproduce:

# gcc -O2 -mcpu=ev67 -o sf2 -lm -mieee-with-inexact sf2.c 
UP1500 ~ # ./sf2 

With FE_INEXACT SIGFPE disabled
2.000000 / 3.000000
fetestexcept(FE_INEXACT) = 2097152
2.000000 / 2.000000
fetestexcept(FE_INEXACT) = 0

With FE_INEXACT SIGFPE enabled
2.000000 / 3.000000
inexact
fetestexcept(FE_INEXACT) = 2097152
2.000000 / 2.000000
fetestexcept(FE_INEXACT) = 0

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mattst88 at gmail dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=9783

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug math/9783] fetestexcept(FE_INEXACT) does not return expected result when inexact trapping is disabled
  2009-01-24 15:38 [Bug math/9783] New: fetestexcept(FE_INEXACT) does not return expected result when inexact trapping is disabled abramo dot bagnara at gmail dot com
  2010-05-04 17:16 ` [Bug math/9783] " mattst88 at gmail dot com
@ 2010-05-04 17:17 ` mattst88 at gmail dot com
  2010-05-05  9:35 ` bagnara at cs dot unipr dot it
  2010-09-12 23:01 ` mattst88 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: mattst88 at gmail dot com @ 2010-05-04 17:17 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING


http://sourceware.org/bugzilla/show_bug.cgi?id=9783

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug math/9783] fetestexcept(FE_INEXACT) does not return expected result when inexact trapping is disabled
  2009-01-24 15:38 [Bug math/9783] New: fetestexcept(FE_INEXACT) does not return expected result when inexact trapping is disabled abramo dot bagnara at gmail dot com
  2010-05-04 17:16 ` [Bug math/9783] " mattst88 at gmail dot com
  2010-05-04 17:17 ` mattst88 at gmail dot com
@ 2010-05-05  9:35 ` bagnara at cs dot unipr dot it
  2010-09-12 23:01 ` mattst88 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: bagnara at cs dot unipr dot it @ 2010-05-05  9:35 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From bagnara at cs dot unipr dot it  2010-05-05 09:34 -------
The only Alpha machine we had access to was gcc30's of the GCC Compile Farm
Project.  According to http://gcc.gnu.org/wiki/CompileFarm this is now offline,
waiting for relocation.


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9783

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug math/9783] fetestexcept(FE_INEXACT) does not return expected result when inexact trapping is disabled
  2009-01-24 15:38 [Bug math/9783] New: fetestexcept(FE_INEXACT) does not return expected result when inexact trapping is disabled abramo dot bagnara at gmail dot com
                   ` (2 preceding siblings ...)
  2010-05-05  9:35 ` bagnara at cs dot unipr dot it
@ 2010-09-12 23:01 ` mattst88 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: mattst88 at gmail dot com @ 2010-09-12 23:01 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From mattst88 at gmail dot com  2010-09-12 23:01 -------
(In reply to comment #2)
> The only Alpha machine we had access to was gcc30's of the GCC Compile Farm
> Project.  According to http://gcc.gnu.org/wiki/CompileFarm this is now offline,
> waiting for relocation.

I tested on another Alpha, with glibc-2.11, and got the same results as I did
before.

I'm going to close this bug as resolved. Please reopen if someone finds otherwise.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |FIXED


http://sourceware.org/bugzilla/show_bug.cgi?id=9783

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2010-09-12 23:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-24 15:38 [Bug math/9783] New: fetestexcept(FE_INEXACT) does not return expected result when inexact trapping is disabled abramo dot bagnara at gmail dot com
2010-05-04 17:16 ` [Bug math/9783] " mattst88 at gmail dot com
2010-05-04 17:17 ` mattst88 at gmail dot com
2010-05-05  9:35 ` bagnara at cs dot unipr dot it
2010-09-12 23:01 ` mattst88 at gmail dot com

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