An alpha IEEE bug

RHS Linux User hjl@lucon.org
Sat Feb 7 12:43:00 GMT 1998


Hi,

There is a bug in the IEEE math on linux/alpha:

# gcc -mieee ieee.c
# a.out
7f800000
1
# gcc -mieee ieee.c -O
# a.out
zsh: 744 abort      ./a.out
# gdb a.out
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16 (alpha-redhat-linux), Copyright 1996 Free Software Foundation, Inc...
(gdb) b isinff
Breakpoint 1 at 0x120000780: file ieee.c, line 16.
(gdb) r
Starting program: /home/work/alpha/bugs/math/a.out

Breakpoint 1, isinff (x=Erroneous arithmetic operation.) at ieee.c:16
16        if (ix == 0)
(gdb)

Can someone please run this on other alpha platforms?


Thanks.


-- 
H.J. Lu (hjl@gnu.org)
----
#include <stdio.h>

typedef int int32_t __attribute__ ((__mode__ (  __SI__ ))) ;
typedef union
{
  float value;
  int32_t word;
} ieee_float_shape_type;

int isinff(float x)
{
  int32_t ix,t;
  ieee_float_shape_type gf_u;
  gf_u.value = x;
  ix = gf_u.word;
  if (ix == 0)
    abort ();
  else
    printf ("%x\n", ix);
  t = ix & 0x7fffffff;
  t ^= 0x7f800000;
  t |= -t;
  return ~(t >> 31) & (1 - ((ix & 0x80000000) >> 30));
}

main ()
{
  float x = 1.0 / 0.0;

  printf ("%d\n", isinff (x));
  return 0;
}



More information about the Gcc mailing list