Thread overview
[Issue 3271] New: Struct initializers silently fail
Aug 29, 2009
nfxjfg@gmail.com
Jan 07, 2011
nfxjfg@gmail.com
Jan 07, 2011
Brad Roberts
Apr 04, 2011
Walter Bright
August 29, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3271

           Summary: Struct initializers silently fail
           Product: D
           Version: 2.031
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: nfxjfg@gmail.com


The following example seems to show, that dmd 2.031 generates invalid code for struct initializers. Test.X contains an empty string instead of "4", and the assertion fails. Amusingly, when using opCall and CTFE instead, it seems to work (version BUG disabled).

PS: the unreduced version of this code also failed under dmd 1.0xx (don't know which version exactly). But this reduced example seems to work under dmd 1.046.

Code:

version = BUG;

struct Test {
    version (BUG) {
        static enum Test X = {value:"4"};
    } else {
        static enum Test X = Test("4");
    }

    string value = "";
}

void main() {
    Test x;
    assert(x.X.value == "4");
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3271


nfxjfg@gmail.com changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3271


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |braddr@puremagic.com
         Resolution|WONTFIX                     |


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 04, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3271


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2011-04-04 16:30:18 PDT ---
https://github.com/D-Programming-Language/dmd/commit/fad0f94a38a0a60888b143d103d9a84145764836

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