This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Alpha Linux gcc bug


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);
}	


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]