Bug 40656 - Can't initial the fields of unamed struct/union.
Summary: Can't initial the fields of unamed struct/union.
Status: RESOLVED DUPLICATE of bug 10676
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-06 06:19 UTC by Changli Gao
Modified: 2009-07-06 19:30 UTC (History)
9 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Changli Gao 2009-07-06 06:19:33 UTC
xiaosuo@gentux test $ cat unamed.c
struct test {
        struct {
                int a;
        };
};

int main()
{
        struct test t1;
        t1.a = 0; /* it is OK */

        struct test t2 = {.a = 0}; /* error */

        return 0;
}
xiaosuo@gentux test $ gcc unamed.c
unamed.c: In function 'main':
unamed.c:12: error: unknown field 'a' specified in initializer
Comment 1 Richard Biener 2009-07-06 10:15:35 UTC
Use

  struct test t2 = { { .a = 0 } };
Comment 2 Andrew Pinski 2009-07-06 19:30:24 UTC
Reopening to ...
Comment 3 Andrew Pinski 2009-07-06 19:30:49 UTC
Mark as a duplicate of bug 10676 which is still open by the way.

*** This bug has been marked as a duplicate of 10676 ***