From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael White To: help-gcc-request@gnu.org Cc: help-gcc@gnu.org Subject: Problems with Sun4 alignment Date: Sat, 01 Apr 2000 00:00:00 -0000 Message-ID: X-SW-Source: 2000-q1/msg00157.html Message-ID: <20000401000000.45H6LIRMRAhv2_yCroK8XjD0b4KdBW2Xhc0izwEooM0@z> Hi all, I'm having a problem with the executable generated by gcc 2.8.1 for Sun 4 (uname -a: SunOS drywall3 4.1.3_U1 2 sun4m). Specifically, I've specified the following flags/defines in tm.h: #define STRICT_ALIGNMENT 1 #define STRUCTURE_SIZE_BOUNDARY 32 Here's the structure I'm having problems with: typedef struct { UBYTE hdr_ver:4; UBYTE data_ver:4; UBYTE reserved:4; UBYTE chan_id:4; UWORD len; UWORD msg_type; STD_SCAP_ADDR dest_addr; UWORD resp_type; XC_SCAP_ADDR src_addr; } SCAP_HDR; Where: #define UBYTE unsigned char #define UWORD unsigned short #define ULONG unsigned long typedef struct { UBYTE system; UBYTE sub_system[2]; UBYTE group; UBYTE device; UBYTE element; } STD_SCAP_ADDR; typedef struct { UBYTE system; UBYTE sub_system; UBYTE device; UBYTE id_1; UBYTE id_2; UBYTE id_3; } XC_SCAP_ADDR; And finally, here's the line that causes a bus fault (SIGBUS): i = *(UWORD *)outgoing_scap_msg->scap_hdr.dest_addr.sub_system; The value of outgoing_scap_msg is 0x3fa89c The value of &outgoing_scap_msg->scap_hdr.dest_addr is 0x3fa8a4 The value of &outgoing_scap_msg->scap_hdr.dest_addr.sub_system 0x3fa8a5 Perhaps I'm way off base here, but it seems to me that when gcc was built, it ignored the STRICT_ALIGNMENT define. This code works correctly under "cc" (the native Sun4 compiler). Any solutions would be greatly appreciated. Please email me if possible. Thank you. --- Michael White, qa1402@ftw.mot.com Cellular Infrastructure Group Ft. Worth, Texas (817)245-6418 P.S. If this is not the proper place to ask these sort of questions, my apologies. If you happen to know the proper place, please tell me and/or forward my email.