gcc-2.7.0 Floating Point Exception bug

gcc-2.7.0 Floating Point Exception bug

Post by Allan Clearwate » Tue, 11 Jul 1995 04:00:00



It has been noticed that the 2.7.0 version of gnu-objc will not
produce a working copy of libobjects on linux.  The problem appears to
be with the function construction functions (__builtin_return and its
compatriots) which are used by part of the gnu objc library.  It is
not a problem with just libobjects or the Objc compiler; the behavior
is provoked by the attached c program.

Along with the sample c code, you will find assembly listings for
testd.c compiled under 2.6.3 and 2.7.0.  The 2.6.3 vesion works; the
2.7.0 version causes a floating point exception message to be printed.
You will note that the 2.6.3 version contains an 'fldz' instruction
after the call to the routine tt; the 2.7.0 assembly does not.

It is unclear to me where this problem is coming from since it has
also been reported that it does not exist under various releases of
netbsd on Intel hardware.  I would assume that the compiler produces
much the same instruction sequence on this platfrom as on Linux, so it
may be that the fp error is not trapped by the netbsd implementation.

In any case, I am firing this message at the gcc, objc, and Linux
community in the hopes that someone will be able to resolve it.  For
the moment, if you wish to run with the 2.7.0 compiler on Linux I
suggest you use a 2.6.3 compiled libobjc.  I've done this and it
appears to be OK.

Thanx,
Al

=======================================================================
= Allan Clearwaters             Phone:  44+(684)569292                =
= MCT Ltd.                      Fax:    44+(684)561153                =
= 62 Albert Rd. North           Email:  al...@mct.co.uk               =
= Malvern, Worcs.                                                     =
= England  WR14 2TL                                                   =
=======================================================================

---------------------------- testd.c ------------------------------
/*
Allan Clearwaters, MCT. Ltd., Malvern, England

This is a small test file that demostrates the "Floatingpoint Execption" problem
that is currently a feature of gnuobjc-2.7.0 on Linux.

Environment:
        i486 with 16 meg running Linux 1.2.11
        gcc-2.7.0 and gcc-2.6.3 configured for i486-linuxaout

Command line:
        gcc -o testd testd.c

*/

#include <stdio.h>

static void tt( void )
{
  printf( "\nin tt\n");
  fflush( stdout );

}

void test( void aFunc( void ) )
{
  int size;
  void *ptr1;

  __builtin_return( __builtin_apply( aFunc,
                                 __builtin_apply_args(),0  ));

}

main()
{
  int i;

  test( tt );
  exit(0);

}

------------- assembly listing for gcc-2.6.3 -------------------------------
        .file   "testd.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
LC0:
        .ascii "\12in tt\12\0"
        .align 4
_tt:
        pushl %ebp
        movl %esp,%ebp
        pushl $LC0
        call _printf
        addl $4,%esp
        pushl $__IO_stdout_
        call _fflush
        addl $4,%esp
L1:
        movl %ebp,%esp
        popl %ebp
        ret
        .align 4
.globl _test
_test:
        pushl %ebp
        movl %esp,%ebp
        subl $128,%esp
        pushl %esi
        pushl %ebx
        leal 8(%ebp),%eax
        movl %eax,-12(%ebp)
        leal -12(%ebp),%eax
        movl (%eax),%eax
        movl %esp,%ebx
        movl %esp,%eax
        movl 8(%ebp),%esi
        call *%esi
        fldz
        movl %eax,-128(%ebp)
        movl %edx,-124(%ebp)
        fstpt -120(%ebp)
        movl %ebx,%esp
        leal -128(%ebp),%ecx
        movl (%ecx),%eax
        movl 4(%ecx),%edx
        fldt 8(%ecx)
        fstp %st(0)
        jmp L2
        .align 4,0x90
L2:
        leal -136(%ebp),%esp
        popl %ebx
        popl %esi
        movl %ebp,%esp
        popl %ebp
        ret
        .align 4
.globl _main
_main:
        pushl %ebp
        movl %esp,%ebp
        subl $4,%esp
        call ___main
        pushl $_tt
        call _test
        addl $4,%esp
        pushl $0
        call _exit
        addl $4,%esp
        .align 4,0x90
L3:
        movl %ebp,%esp
        popl %ebp
        ret

------------------- assembly listing for gcc-2.7.0 ---------------------
        .file   "testd.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
LC0:
        .ascii "\12in tt\12\0"
        .align 4
_tt:
        pushl %ebp
        movl %esp,%ebp
        pushl $LC0
        call _printf
        addl $4,%esp
        pushl $__IO_stdout_
        call _fflush
        addl $4,%esp
L1:
        movl %ebp,%esp
        popl %ebp
        ret
        .align 4
.globl _test
_test:
        pushl %ebp
        movl %esp,%ebp
        subl $140,%esp
        pushl %esi
        pushl %ebx
        movl %eax,-20(%ebp)
        movl %edx,-16(%ebp)
        movl %ecx,-12(%ebp)
        leal 8(%ebp),%eax
        movl %eax,-24(%ebp)
        leal -24(%ebp),%ecx
        movl (%ecx),%eax
        movl %esp,%ebx
        movl %esp,%edx
        movl 4(%ecx),%eax
        movl 8(%ecx),%edx
        movl 12(%ecx),%ecx
        movl 8(%ebp),%esi
        call *%esi
        movl %eax,-140(%ebp)
        movl %edx,-136(%ebp)
        fstpt -132(%ebp)
        movl %ebx,%esp
        leal -140(%ebp),%ecx
        movl (%ecx),%eax
        movl 4(%ecx),%edx
        fldt 8(%ecx)
        fstp %st(0)
        jmp L2
        .align 4,0x90
L2:
        leal -148(%ebp),%esp
        popl %ebx
        popl %esi
        movl %ebp,%esp
        popl %ebp
        ret
        .align 4
.globl _main
_main:
        pushl %ebp
        movl %esp,%ebp
        subl $4,%esp
        call ___main
        pushl $_tt
        call _test
        addl $4,%esp
        pushl $0
        call _exit
        addl $4,%esp
        .align 4,0x90
L3:
        movl %ebp,%esp
        popl %ebp
        ret
--

=======================================================================
= Allan Clearwaters             Phone:  44+(684)569292                =
= MCT Ltd.                      Fax:    44+(684)561153                =
= 62 Albert Rd. North           Email:  al...@mct.co.uk               =
= Malvern, Worcs.                                                     =
= England  WR14 2TL                                                   =
=======================================================================

 
 
 

1. Floating point exception with GCC

I seem to be having a problem with floating point exceptions (signal
8).  The code
was originally written and compiled on an HP.  I never had any problem
on that system.
Maybe somebody has seen this before??

1)  The code links c, c++, and fortran libraries.   All compiled  with
gcc, g++, and g77

2) It is not a consistant thing, happens every once in a while

3) I've tried recompiling everything with "-mieee-fp" set as a compiler
option, did not
   help.

4) Compiler version (gcc --version):  egcs-2.91.66

Thanks

--------------
Wm. Randy Esposito



(609) 258-6754                  Princeton University
                                http://titan.princeton.edu

2. Run Away scsi_eh_1 , Load was still climbing .

3. gcc 2.3.3 floating point exception (test C code included)

4. MkLinux - X - ?

5. Floating point exceptions, gcc 3.2 and -mfpmath=sse

6. Problems when boot new kernel 2.5.66 kernel panic

7. Floating point exception in 2.0.22 (Bug?)

8. nfs mount from linux to linux

9. continuing after a floating point exception (FPE) and maximizing FP performance using ccc and gcc

10. continuing after a floating point exceptions (FPE) and maximizing FP performance using ccc or gcc

11. Floating-point bugs in GCC

12. Floating Point Exception

13. float point exception on 3.0