This is the mail archive of the gcc-bugs@gcc.gnu.org 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;
  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: libm nextafter and nextafterf fail to set IEEE exception
                    flags
           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


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


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