Alpha Linux gcc bug
Arun Sharma
asharma@netscape.com
Wed Mar 18 13:12:00 GMT 1998
The following message is a courtesy copy of an article
that has been posted to gnu.gcc.bug as well.
The following program core dumps, when converting the double to an
int. Can someone explain why ?
This was tested with both gcc-2.7.2 and egcs-1.0.1
-Arun
#include <stdio.h>
#include <endian.h>
typedef unsigned int uint32;
union dpun {
struct {
#ifdef IS_LITTLE_ENDIAN
uint32 lo, hi;
#else
uint32 hi, lo;
#endif
} s;
double d;
};
double d;
int i;
#define DOUBLE_HI32_EXPMASK 0x7ff00000
#define DOUBLE_HI32_MANTMASK 0x000fffff
main()
{
union dpun u;
u.s.hi = DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK;
u.s.lo = 0xffffffff;
i = (int) u.d;
printf("%f\n", u.d);
}
More information about the Gcc-bugs
mailing list