[LLVMbugs] [Bug 6741] New: Can't have multiple anonymous unions which redeclare members

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 29 21:32:02 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=6741

           Summary: Can't have multiple anonymous unions which redeclare
                    members
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: alexmac at adobe.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Created an attachment (id=4610)
 --> (http://llvm.org/bugs/attachment.cgi?id=4610)
testcase

Perhaps this is a violation of the spec and clang is right to disallow it,
however it does crop up in "real world" code so it *might* be better for this
to be a warning rather than an error. Here is a small example of what I'm
talking about

p.s. As it happens the one use of this in the AVM code base is entirely
frivolous and can easily be removed, but perhaps it affects other codebases...

void foo() {
    union {
        char *m_a;
        int *m_b;
    };
    // some code

    if(somecondition) {
        union {
            char *m_a;
            int *m_b;
        };
        // some code
    }
}

Currently clang gives you the following error:

union-bug.cpp:11:10: error: member of anonymous union redeclares 'm_a'
                        char *m_a;
                              ^
union-bug.cpp:5:9: note: previous declaration is here
                char *m_a;

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list