[Bug 44] New: forward referenced anonymous union in struct size discrepancy

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 12 12:22:18 PST 2006


http://d.puremagic.com/bugzilla/show_bug.cgi?id=44

           Summary: forward referenced anonymous union in struct size
                    discrepancy
           Product: D
           Version: 0.149
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: regan at netwin.co.nz


If B is declared before A, or the union in A is named (and an instance added)
then the sizeof A is 12 as it should be. In the example below it is 8.

struct A {
        int a;
        union {
                int c;
                B b;
        }
}

struct B {
        int b1;
        int b2;
}

void main()
{
        A a;
        assert(A.sizeof == 12);
}


-- 




More information about the Digitalmars-d-bugs mailing list