[LLVMbugs] [Bug 7855] New: Initialization of an anonymous struct within a class

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 9 16:13:55 PDT 2010


           Summary: Initialization of an anonymous struct within a class
           Product: clang
           Version: 2.7
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: sjackman at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


I'm not sure whether an anonymous struct within a class is standard, or
a GCC extension that clang attempts to support. In any case, the
following code snippet gives this error:

anonymous-struct.cc:7:16: error: multiple initializations given for non-static
member 'y'
        Foo() : x(0), y(0) { }
anonymous-struct.cc:7:10: note: previous initialization is here
        Foo() : x(0), y(0) { }
2 diagnostics generated.


struct Foo
        struct {
                int x;
                int y;
        Foo() : x(0), y(0) { }

#include <iostream>

int main()
        Foo foo;
        std::cout << foo.x << ' ' << foo.y << '\n';
        return 0;

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