[Issue 7930] New: Static initialization of static-sized array in union fails

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 16 18:34:05 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7930

           Summary: Static initialization of static-sized array in union
                    fails
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: marcianx at gmail.com


--- Comment #0 from marcianx at gmail.com 2012-04-16 18:34:56 PDT ---
I tried this on DMD64 v2.059 on linux (openSUSE).

Static initialization of a static-sized array within a union seems to 
assign only the first entry of the array. If the array is taken out of 
the union and the union is removed, then the initialization works fine.

struct Klass
{
    union {
        double[3] vals = void;
        struct { double x, y, z; }
    }
}

void main()
{
    Klass v = {[1,2,3]};

    import std.stdio;
    writeln(v.vals); // outputs [1, nan, nan]; expected [1, 2, 3]
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list