[Issue 15938] ctor doesn't initialize fields when struct is static immutable

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Sep 21 16:04:04 PDT 2016


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

John Colvin <john.loughran.colvin at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.loughran.colvin at gmail.
                   |                            |com

--- Comment #2 from John Colvin <john.loughran.colvin at gmail.com> ---
Simplified example:

struct S {
        union {
                // works if order swapped
                int b;
                int[1] a;
        }

        this(int v) {
                a[0] = v;
        }
}                                            
auto s = S(2);

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

--


More information about the Digitalmars-d-bugs mailing list