[Issue 3271] New: Struct initializers silently fail

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 29 08:45:37 PDT 2009


           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 at puremagic.com
        ReportedBy: nfxjfg at 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.


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

More information about the Digitalmars-d-bugs mailing list