This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/29351] New: libm nextafter and nextafterf fail to set IEEE exception flags

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.) On an X8664 architecture with the -m64
option it does so, but with the -m32 option it does 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;
  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-
--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
#include "..." search starts here:
#include <...> search starts here:
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 (x86_64-redhat-linux) using BFD version 20060212
 /usr/libexec/gcc/x86_64-redhat-linux/4.1.1/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ -o csjc.m32
-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
-bash-3.1$ gcc -o csjc.m64 -m64 csjc.c -lm
-bash-3.1$ ./csjc.m32
nextafterf: 7fffff
fetestexcept: 0
-bash-3.1$ ./csjc.m64
nextafterf: 7fffff
fetestexcept: 30

           Summary: libm nextafter and nextafterf fail to set IEEE exception
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sjc at pobox dot com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]