www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3271] New: Struct initializers silently fail

reply d-bugmail puremagic.com writes:
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: -------
Aug 29 2009
next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 06 2011
prev sibling parent d-bugmail puremagic.com writes:
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: -------
Apr 04 2011