[Issue 18078] [CTFE] wrong initialization of array member with inout opIndex

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 18 20:47:55 UTC 2018


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

bitter.taste at gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bitter.taste at gmx.com

--- Comment #1 from bitter.taste at gmx.com ---
Reduced to:

---
struct S
{
    int x;
    version (problem) void opAssign(S o) { x = o.x; }
}

struct Foo
{
    S[1] data;
    ref inout(S) g() inout { return data[0]; }
    this(S a) { g() = a; }
}

void main()
{
    enum x = Foo(S(42));
    assert(x.data[0].x == 42);
}
---

The problem disappears if you remove `opAssign` (or the inout qualifiers).

--


More information about the Digitalmars-d-bugs mailing list