[Issue 11147] New: Nested structs in a union are not correctly initialized

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 30 01:43:45 PDT 2013


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

           Summary: Nested structs in a union are not correctly
                    initialized
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: industry, spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrea.9940 at gmail.com


--- Comment #0 from andrea.9940 at gmail.com 2013-09-30 01:43:43 PDT ---
DMD version: 2.063.2

The value of all variables in V should be zero, but the output shows they
aren't.

---------------
struct V {
    union {
        struct {
            float x = 1;
            float y = 1;
        float z = 1;
        }
        struct {
            float r;
            float g;
        float b;
        }
    }
}
import std.stdio;
void main() {
    writeln("V(", V.init.x, ", ", V.init.y, ", ", V.init.z, ", ", V.init.r, ",
", V.init.g, ", ", V.init.b, ")");
    writeln(V.init);
    writeln(V(V.init.x, V.init.y, V.init.z));
}
---------------

V(0, 0, 0, 0, 0, 0)
V(0, nan, nan, 0, nan, nan)
V(0, 0, 0, 0, 0, 0)

-- 
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