www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10937] New: struct inside union gives uninitialized error in CTFE

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: destructionator gmail.com


--- Comment #0 from Adam D. Ruppe <destructionator 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: -------
Aug 31 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10937



--- Comment #1 from github-bugzilla puremagic.com 2013-09-17 22:56:14 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/b33b138f632c049b5cfb52ebbbac35b426557f4c
Fix bug 10937 struct inside union gives uninitialized error in CTFE

Remove over-zealous assert, add comments to explain why.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 17 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10937


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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