Thread overview
[Issue 18078] [CTFE] wrong initialization of array member with inout opIndex
Aug 18, 2018
ag0aep6g
Dec 17, 2022
Iain Buclaw
March 18, 2018
https://issues.dlang.org/show_bug.cgi?id=18078

bitter.taste@gmx.com changed:

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

--- Comment #1 from bitter.taste@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).

--
August 18, 2018
https://issues.dlang.org/show_bug.cgi?id=18078

ag0aep6g <ag0aep6g@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |ag0aep6g@gmail.com

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=18078

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--