Bug 540047
| Summary: | Can't use labeled elements in initializers for structs with unnamed union fields | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Casey Dahlin <cdahlin> | ||||
| Component: | gcc | Assignee: | Jakub Jelinek <jakub> | ||||
| Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | low | ||||||
| Version: | 12 | CC: | jakub, vanhoof | ||||
| Target Milestone: | --- | ||||||
| Target Release: | --- | ||||||
| Hardware: | All | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2009-11-23 07:49:10 UTC | Type: | --- | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Attachments: |
|
||||||
Why do you think it is a bug? ISO C99 designated initializers require that the identifier identifies a field in the current structure/union, which is not the case. |
Created attachment 372842 [details] Reproducer Description of problem: If you try to use a struct with an unnamed union field, for example: struct foo { int bar; union { int baz; int bam; }; }; And then try to statically initialize one using field labels like so: struct foo mine = { .bar = 1, .baz = 2 }; you get: error: unknown field ‘baz’ specified in initializer Version-Release number of selected component (if applicable): gcc-4.4.2-7.fc12 Steps to Reproduce: Try compiling the attached program. Actual results: reproducer.c:13: error: unknown field ‘baz’ specified in initializer Expected results: Compiles. mine.bar == 1, mine.baz == mine.bam == 2