Bug 47376 - Duplicate member through anonymous unions not reported
Summary: Duplicate member through anonymous unions not reported
Status: RESOLVED DUPLICATE of bug 4784
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-20 12:59 UTC by Jan Engelhardt
Modified: 2011-02-07 02:00 UTC (History)
0 users

See Also:
Host: x86_64-suse-linux
Target: x86_64-suse-linux
Build: x86_64-suse-linux
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 Jan Engelhardt 2011-01-20 12:59:58 UTC
Given the following example:
---
struct foo {
        int a;
        union {
                int a;
                double b;
        };
};

int main(void)
{
        struct foo f;
        f.a = 123;
        return 0;
}
---

How it came to be:
Accidental error where I had forgotten to remove foo.a after having added foo.{anonymous}.a.

What has been observed:
It compiles fine, which caused this programming error of mine to go unnoticed for half a day. It seems gcc gives foo.a precedence over foo.{anonymous}.a when accessing it through f.a=....

What had been expected:
I would have liked that gcc emit at least a warning because f.a is ambiguous.
Comment 1 Joseph S. Myers 2011-02-07 01:59:50 UTC
Fixed in 4.6.
Comment 2 Joseph S. Myers 2011-02-07 02:00:15 UTC
Fixed in 4.6.

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