This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members
- From: "jakub at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Jun 2005 08:52:10 -0000
- Subject: [Bug tree-optimization/22043] New: [4.0/4.1 Regression] Fields not initialized for automatic structs with flexible array members
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In:
extern void abort (void);
struct A { int i; int j; int k; int l; };
struct B { struct A a; int r[1]; };
struct C { struct A a; int r[0]; };
struct D { struct A a; int r[]; };
void
foo (struct A *x)
{
if (x->i != 0 || x->j != 5 || x->k != 0 || x->l != 0)
abort ();
}
int
main ()
{
struct B b = { .a.j = 5 };
struct C c = { .a.j = 5 };
struct D d = { .a.j = 5 };
foo (&b.a);
foo (&c.a);
foo (&d.a);
return 0;
}
GCC 4.0/HEAD only zero initialize a.i, a.k and a.l for the b variable, not for
c nor d, while 3.4.x and older initialized them for all 3 variables.
This causes miscompilation of glibc by GCC 4.0+.
--
Summary: [4.0/4.1 Regression] Fields not initialized for
automatic structs with flexible array members
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at redhat dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22043