Commit e334b681 authored by Raymond Toy's avatar Raymond Toy
Browse files

Fix aliasing issue noted by gcc 4.4.1 on Linux.

I think the offending code in each case is trying to extract the low
word if x. I think it works because on a little-endian machine,
*(unsigned*)&one is 0 since the low word is stored first. On a
big-endian machine, *(unsigned*)&one is the high word which, when
right shifted by 29, gives 1.  That is added to the address of x to
get the low word of x.
parent 022325cc
......@@ -78,7 +78,11 @@ static double one = 1.0, half=0.5, huge = 1.0e300;
if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x));
/* |x| in [log(maxdouble), overflowthresold] */
#if 0
lx = *( (((*(unsigned*)&one)>>29)) + (unsigned*)&x);
#else
lx = ux.i[LOWORD];
#endif
if (ix<0x408633CE ||
((ix==0x408633ce)&&(lx<=(unsigned)0x8fb9f87d))) {
w = __ieee754_exp(half*fabs(x));
......
......@@ -72,7 +72,11 @@ static double one = 1.0, shuge = 1.0e307;
if (ix < 0x40862E42) return h*__ieee754_exp(fabs(x));
/* |x| in [log(maxdouble), overflowthresold] */
#if 0
lx = *( (((*(unsigned*)&one)>>29)) + (unsigned*)&x);
#else
lx = ux.i[LOWORD];
#endif
if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(unsigned)0x8fb9f87d))) {
w = __ieee754_exp(0.5*fabs(x));
t = h*w;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment