a long-standing reload bug
Zack Weinberg
zack@rabi.columbia.edu
Thu Oct 29 20:11:00 GMT 1998
Now that Bernd's reload changes are all in, it's appropriate to bring
this up again. egcs/CVS of last night (around 10pm EDT) gets an ICE
on the appended code when compiled with any optimization:
../../../egcs/gcc/reload.c:4403: Internal compiler error in function
find_reloads_toplev
The CVS mainline has been doing this since shortly after 1.1 (I
think). It doesn't happen with 1.0.3. I don't have 1.1 around to
test. Platform is x86. The code comes from glibc's math tests.
zw
-- test.c --
enum
{
FE_INVALID = 0x01,
__FE_DENORM = 0x02,
FE_DIVBYZERO = 0x04,
FE_OVERFLOW = 0x08,
FE_UNDERFLOW = 0x10,
FE_INEXACT = 0x20
};
static int noErrors;
static double nan_value;
extern int puts (const char *);
extern void check_isinfp (const char *, double);
extern void check_isinfn (const char *, double);
extern void check_bool (const char *, int);
extern void check_isnan (const char *, double);
extern int __isinf (double) __attribute__ ((__const__));
extern int __isinff (float) __attribute__ ((__const__));
extern int __isinfl (long double) __attribute__ ((__const__));
extern int isinff (float) __attribute__ ((__const__));
extern int isinfl (long double) __attribute__ ((__const__));
extern int __isnan (double) __attribute__ ((__const__));
extern int __isnanf (float) __attribute__ ((__const__));
extern int __isnanl (long double) __attribute__ ((__const__));
extern double nan (const char *);
extern void feclearexcept (int);
static void
basic_tests (void)
{
int p_noErrors = noErrors;
volatile double Inf_var, NaN_var, zero_var, one_var;
double x1, x2;
zero_var = 0.0;
one_var = 1.0;
NaN_var = nan_value;
Inf_var = one_var / zero_var;
(void) &zero_var;
(void) &one_var;
(void) &NaN_var;
(void) &Inf_var;
feclearexcept ((FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID));
check_isinfp ("isinf (inf) == +1", Inf_var);
check_isinfn ("isinf (-inf) == -1", -Inf_var);
check_bool ("!isinf (1)", !((sizeof (one_var) == sizeof (float) ? __isinff (one_var) : sizeof (one_var) == sizeof (double) ? __isinf (one_var) : __isinfl (one_var))));
check_bool ("!isinf (NaN)", !((sizeof (NaN_var) == sizeof (float) ? __isinff (NaN_var) : sizeof (NaN_var) == sizeof (double) ? __isinf (NaN_var) : __isinfl (NaN_var))));
check_isnan ("isnan (NaN)", NaN_var);
check_isnan ("isnan (-NaN)", -NaN_var);
check_bool ("!isnan (1)", !((sizeof (one_var) == sizeof (float) ? __isnanf (one_var) : sizeof (one_var) == sizeof (double) ? __isnan (one_var) : __isnanl (one_var))));
check_bool ("!isnan (inf)", !((sizeof (Inf_var) == sizeof (float) ? __isnanf (Inf_var) : sizeof (Inf_var) == sizeof (double) ? __isnan (Inf_var) : __isnanl (Inf_var))));
check_bool ("inf == inf", Inf_var == Inf_var);
check_bool ("-inf == -inf", -Inf_var == -Inf_var);
check_bool ("inf != -inf", Inf_var != -Inf_var);
check_bool ("NaN != NaN", NaN_var != NaN_var);
check_bool ("isnan (NAN)", (sizeof ((__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) == sizeof (float) ? __isnanf ((__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) : sizeof ((__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) == sizeof (double) ? __isnan ((__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) : __isnanl ((__extension__ ((union !
{ unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d))));
check_bool ("isnan (-NAN)", (sizeof (-(__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) == sizeof (float) ? __isnanf (-(__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) : sizeof (-(__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) == sizeof (double) ? __isnan (-(__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) : __isnanl (-(__extension__ ((!
union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d))));
check_bool ("!isinf (NAN)", !((sizeof ((__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) == sizeof (float) ? __isinff ((__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) : sizeof ((__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) == sizeof (double) ? __isinf ((__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) : __isinfl ((__extension__ ((uni!
on { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)))));
check_bool ("!isinf (-NAN)", !((sizeof (-(__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) == sizeof (float) ? __isinff (-(__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) : sizeof (-(__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) == sizeof (double) ? __isinf (-(__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)) : __isinfl (-(__extension__ !
((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d)))));
check_bool ("NAN != NAN", (__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d) != (__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x7fc00000UL }).__d));
check_bool ("isnan (NAN)", (sizeof (nan ("")) == sizeof (float) ? __isnanf (nan ("")) : sizeof (nan ("")) == sizeof (double) ? __isnan (nan ("")) : __isnanl (nan (""))));
check_bool ("isnan (-NAN)", (sizeof (-nan ("")) == sizeof (float) ? __isnanf (-nan ("")) : sizeof (-nan ("")) == sizeof (double) ? __isnan (-nan ("")) : __isnanl (-nan (""))));
check_bool ("!isinf (NAN)", !((sizeof (nan ("")) == sizeof (float) ? __isinff (nan ("")) : sizeof (nan ("")) == sizeof (double) ? __isinf (nan ("")) : __isinfl (nan ("")))));
check_bool ("!isinf (-NAN)", !((sizeof (-nan ("")) == sizeof (float) ? __isinff (-nan ("")) : sizeof (-nan ("")) == sizeof (double) ? __isinf (-nan ("")) : __isinfl (-nan ("")))));
check_bool ("NAN != NAN", nan ("") != nan (""));
x1 = 1.0;
x2 = x1 + 2.2204460492503131e-16;
check_bool ("1 != 1+EPSILON", x1 != x2);
x1 = 1.0;
x2 = x1 - 2.2204460492503131e-16;
check_bool ("1 != 1-EPSILON", x1 != x2);
x1 = (__extension__ ((union { unsigned char __c[8]; double __d; }) { __c: { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }).__d);
check_bool ("isinf (HUGE_VALx) == +1", (sizeof (x1) == sizeof (float) ? isinff (x1) : sizeof (x1) == sizeof (double) ? (sizeof (x1) == sizeof (float) ? __isinff (x1) : sizeof (x1) == sizeof (double) ? __isinf (x1) : __isinfl (x1)) : isinfl (x1)) == +1);
x1 = - (__extension__ ((union { unsigned char __c[8]; double __d; }) { __c: { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }).__d);
check_bool ("isinf (-HUGE_VALx) == -1", (sizeof (x1) == sizeof (float) ? isinff (x1) : sizeof (x1) == sizeof (double) ? (sizeof (x1) == sizeof (float) ? __isinff (x1) : sizeof (x1) == sizeof (double) ? __isinf (x1) : __isinfl (x1)) : isinfl (x1)) == -1);
puts((p_noErrors < noErrors) ? "n" : "y");
}
More information about the Gcc-bugs
mailing list