[Issue 10937] New: struct inside union gives uninitialized error in CTFE

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 31 18:29:58 PDT 2013


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

           Summary: struct inside union gives uninitialized error in CTFE
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: destructionator at gmail.com


--- Comment #0 from Adam D. Ruppe <destructionator at gmail.com> 2013-08-31 18:29:57 PDT ---
===

struct Test {
    union {
        ubyte[1] a;
        struct {
            ubyte b;
        }
    }

    this(ubyte B) {
        this.b = B; // this triggers the error below
        // this.a[0] = B; // this works
    }
}

enum test = Test(0); // test30.d(9): Error: uninitialized variable 'b' cannot
be returned from CTFE

===

Both constructor lines work fine at runtime.

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