This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/47376] New: Duplicate member through anonymous unions not reported


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47376

           Summary: Duplicate member through anonymous unions not reported
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jengelh@medozas.de
              Host: x86_64-suse-linux
            Target: x86_64-suse-linux
             Build: x86_64-suse-linux


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]