From mboxrd@z Thu Jan 1 00:00:00 1970 From: hjl@lucon.org (RHS Linux User) To: egcs@cygnus.com Cc: rth@cygnus.com Subject: An alpha IEEE bug Date: Sat, 07 Feb 1998 12:43:00 -0000 Message-id: X-SW-Source: 1998-02/msg00270.html 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 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; }