This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug math/3306] New: nextafter and nextafterf fail to raise IEEE exceptions
- From: "sjc at pobox dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 5 Oct 2006 03:37:43 -0000
- Subject: [Bug math/3306] New: nextafter and nextafterf fail to raise IEEE exceptions
- Reply-to: sourceware-bugzilla at sourceware dot org
The man page for "nextafter" and "nextafterf" states that they will signal
overflow and underflow if the result is not a normalized number (and I believe
they should signal "inexact" as well, based on section F.9.8.3 of ISO/IEC
9899:TC2, the "C99" standard.) On an X8664 architecture with the -m64 option the
functions do so, but with the -m32 option they do not. I reproduced this on
various versions of Fedora Core OS with both gcc 3 and gcc 4, so it appears to
be a longstanding problem:
-bash-3.1$ cat csjc.c
#include <stdio.h>
#include <math.h>
#include <fenv.h>
int main(int argc, char **argv) {
float x, s, y;
* ((unsigned *) &x) = 0x00800000;
s = 0.0;
feclearexcept(FE_ALL_EXCEPT);
y = nextafterf(x, s);
unsigned i = fetestexcept(FE_ALL_EXCEPT);
printf("nextafterf: %x\n", * ((unsigned *) &y));
printf("fetestexcept: %x\n", i);
printf("FE_UNDERFLOW: %x\n", FE_UNDERFLOW);
printf("FE_INEXACT: %x\n", FE_INEXACT);
return 0;
}
-bash-3.1$ gcc -v -save-temps -o csjc.m32 -m32 csjc.c -lm
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.1 20060525 (Red Hat 4.1.1-1)
/usr/libexec/gcc/x86_64-redhat-linux/4.1.1/cc1 -E -quiet -v csjc.c -m32
-mtune=generic -fpch-preprocess -o csjc.i
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/4.1.1/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include
/usr/include
End of search list.
/usr/libexec/gcc/x86_64-redhat-linux/4.1.1/cc1 -fpreprocessed csjc.i -quiet
-dumpbase csjc.c -m32 -mtune=generic -auxbase csjc -version -o csjc.s
GNU C version 4.1.1 20060525 (Red Hat 4.1.1-1) (x86_64-redhat-linux)
compiled by GNU C version 4.1.1 20060525 (Red Hat 4.1.1-1).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 990baec469b77ffbcfce8c2c8d27c0bf
as -V -Qy --32 -o csjc.o csjc.s
GNU assembler version 2.16.91.0.6 (x86_64-redhat-linux) using BFD version
2.16.91.0.6 20060212
/usr/libexec/gcc/x86_64-redhat-linux/4.1.1/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 -o csjc.m32
/usr/lib/gcc/x86_64-redhat-linux/4.1.1/../../../../lib/crt1.o
/usr/lib/gcc/x86_64-redhat-linux/4.1.1/../../../../lib/crti.o
/usr/lib/gcc/x86_64-redhat-linux/4.1.1/32/crtbegin.o
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/32
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/32
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/../../../../lib -L/lib/../lib
-L/usr/lib/../lib csjc.o -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc
--as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/x86_64-redhat-linux/4.1.1/32/crtend.o
/usr/lib/gcc/x86_64-redhat-linux/4.1.1/../../../../lib/crtn.o
-bash-3.1$ gcc -o csjc.m64 -m64 csjc.c -lm
-bash-3.1$ ./csjc.m32
nextafterf: 7fffff
fetestexcept: 0
FE_UNDERFLOW: 10
FE_INEXACT: 20
-bash-3.1$ ./csjc.m64
nextafterf: 7fffff
fetestexcept: 30
FE_UNDERFLOW: 10
FE_INEXACT: 20
--
Summary: nextafter and nextafterf fail to raise IEEE exceptions
Product: glibc
Version: 2.4
Status: NEW
Severity: normal
Priority: P2
Component: math
AssignedTo: aj at suse dot de
ReportedBy: sjc at pobox dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=3306
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.