This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21387] New: Unaligned writes on MIPSEL systems after typecast
- From: "maarten at contemplated dot nl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 May 2005 19:07:57 -0000
- Subject: [Bug c++/21387] New: Unaligned writes on MIPSEL systems after typecast
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
See code below. After type-casting, the compiler incorrectly assumes that
'a.unaligned_int' is aligned on a word boundary. On a MIPSEL system (here a
Cobalt RaQ 2) a 'sw' assembler instruction is generated to store the value in
memory, resulting in a 'Segmentation fault'. Changing the 'sw' instruction to
'swl', the problem is solved.
#include <stdint.h>
#pragma pack(1)
typedef struct {
int8_t byte;
int32_t unaligned_int;
} test_unaligned;
#pragma pack()
int main(int argc, char *argv[]) {
test_unaligned a;
*((int32_t *) a.unaligned_int) = 0x123456;
return(0);
}
--
Summary: Unaligned writes on MIPSEL systems after typecast
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: maarten at contemplated dot nl
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: mipsel-netbsd2.0
GCC host triplet: mipsel-netbsd2.0
GCC target triplet: mipsel-netbsd2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21387