This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: 3 pending patches from 2002
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 8 Jan 2003 20:59:07 +0100
- Subject: Re: 3 pending patches from 2002
- References: <14980000.1041902728@warlock.codesourcery.com>
> > PR c/8032:
> > http://gcc.gnu.org/ml/gcc-patches/2002-11/msg01636.html
> > Probably not worth applying on the 3.2 branch.
>
> Does this work if the constructor is skipping around a lot, e.g.:
>
> struct S { int a; int b; int c; int d; };
>
> struct S s = { .c = 3, .a = 7, 6 };
>
> I don't remember what the "6" is supposed to initialize (b? d?), but
> we should make sure your patch does the right thing.
As Jakub said, 6 is supposed to initialize the member which follows "a".
The patch lets the attached testcase pass for gcc 3.2.2, gcc 3.3 and gcc 3.4
(without it, only the first half of testcase is correctly compiled).
Should I add it alongside the original testcase ? (Perhaps experienced C
front-end hackers could comment on whether such a testcase already exists in
the testsuite).
Richard approved the patch for all branches yesterday. Should I take the
intersection or the union of your respective approvals ? :-)
--
Eric Botcazou
extern void abort(void);
struct S
{
int a;
int b;
int c;
int d;
};
struct S s1 = { .c = 3, .a = 1, 2 };
struct S s2 = { 1, .d = 4, .c = 3 };
struct S s3 = { .d = 4, .c = 3, .b = 2 };
struct S s4 = { .b = 2 };
struct T
{
int a;
int b;
int c;
int d;
char s[];
};
struct T t1 = { .c = 3, .s = {}, .a = 1, 2 };
struct T t2 = { 1, .s = {}, .d = 4, .c = 3 };
struct T t3 = { .s = {} , .d = 4, .c = 3, .b = 2 };
struct T t4 = { .b = 2, .s = {} };
int main(void)
{
if (s1.a != 1 || s1.b != 2 || s1.c != 3 || s1.d != 0)
abort();
if (s2.a != 1 || s2.b != 0 || s2.c != 3 || s2.d != 4)
abort();
if (s3.a != 0 || s3.b != 2 || s3.c != 3 || s3.d != 4)
abort();
if (s4.a != 0 || s4.b != 2 || s4.c != 0 || s4.d != 0)
abort();
if (t1.a != 1 || t1.b != 2 || t1.c != 3 || t1.d != 0)
abort();
if (t2.a != 1 || t2.b != 0 || t2.c != 3 || t2.d != 4)
abort();
if (t3.a != 0 || t3.b != 2 || t3.c != 3 || t3.d != 4)
abort();
if (t4.a != 0 || t4.b != 2 || t4.c != 0 || t4.d != 0)
abort();
return 0;
}