This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/57180] New: Structures with a flexible arrray member have wrong size
- From: "amodra at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 05 May 2013 23:42:42 +0000
- Subject: [Bug c/57180] New: Structures with a flexible arrray member have wrong size
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57180
Bug #: 57180
Summary: Structures with a flexible arrray member have wrong
size
Classification: Unclassified
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: amodra@gmail.com
CC: algrant@acm.org, amodra@gmail.com,
fredrickprashanth@gmail.com, gcc-bugs@gcc.gnu.org,
lauro.venancio@gmail.com, qrczak@knm.org.pl,
sbsiddha@gmail.com
Depends on: 28865
+++ This bug was initially created as a clone of Bug #28865 +++
Cloned from 28865, because the problem is more than just getting .size wrong.
The following testcase fails on all targets at all optimization levels.
The testcase was taken from glibc/nss/nss_files/files-init.c, which is
miscompiled on powerpc or any other target using -fsection-anchors.
union
{
struct { long j; char c[]; } s;
char pad[32];
} x[2] =
{
{ .s = { .c = "abc123" } },
{ .s = { .c = "xyz" } }
};
int
main (void)
{
if (sizeof (x[0]) != 32)
__builtin_abort ();
if (x[1].s.c[0] != 'x')
__builtin_abort ();
return 0;
}