This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/16038] New: Bug in handling packed structures on MIPS
- From: "ian at wasabisystems dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Jun 2004 20:00:25 -0000
- Subject: [Bug middle-end/16038] New: Bug in handling packed structures on MIPS
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider this test case:
struct in_addr {
unsigned int s_addr;
} __attribute__((__packed__));
struct MemberInfo_t {
char membername[1];
struct in_addr ipaddrs[3];
};
extern void bar (struct in_addr);
void foo(struct MemberInfo_t *p)
{
unsigned int i;
for (i = 0; i < 3; i++)
if (p->ipaddrs[i].s_addr != 0)
bar(p->ipaddrs[i]);
}
Compiling this with the 3.3 branch targeted for mips-elf, with -O, produces code
which includes these lines:
sll $2,$16,2
addu $3,$2,$17
ulw $2,1($3)
#nop
beq $2,$0,$L4
lw $4,1($3)
jal bar
This is wrong. The lw is an unaligned access, and must actually be ulw.
This is fixed in 3.4.0. The patch can be found here:
http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00299.html
If there is going to be a 3.3.5 release, I propose that this patch be brought
onto the 3.3 branch.
This testcase arises in the NetBSD sources.
--
Summary: Bug in handling packed structures on MIPS
Product: gcc
Version: 3.3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at wasabisystems dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: mips-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16038