https://issues.dlang.org/show_bug.cgi?id=15938

          Issue ID: 15938
           Summary: ctor doesn't initialize fields when struct is static
                    immutable
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: temta...@gmail.com

struct S {
    static foo() { int[1][1] res = 1; return res; }

    union {
        int[1][1] A = foo;
        int[1] flat;
    }

    this(A...)(auto ref in A args) {
        uint k;

        foreach(v; args)
            flat[k++] = v;
    }
}

static immutable s = S(2);

void main() {
    assert(s.flat[0] == 2); // fails
    assert(S(2).flat[0] == 2);
}

--

Reply via email to