This is a reduction of issue 16011. Fixing this possibly also fixes that one, but since this fails with different versions of dmd, there may be something else going on in addition.
----
void emplace(S* chunk) { *chunk = S.init; }
struct RefCounted()
{
struct RefCountedStore
{
struct Impl { S _payload; }
Impl* _store;
void initialize()
{
_store = new Impl; /* line 13 */
emplace(&_store._payload); /* line 14 */
}
}
RefCountedStore _refCounted;
void opAssign(typeof(this) rhs) {}
void opAssign(S rhs) {}
ref S refCountedPayload()
{
if (_refCounted._store is null) _refCounted.initialize();
return _refCounted._store._payload;
}
alias refCountedPayload this;
}
struct S
{
int x;
RefCounted!() s;
}
void main()
{
S s;
s.x = 1;
s.s.x = 2;
s.s.s.x = 3;
assert(s.x == 1);
assert(s.s.x == 2);
assert(s.s.s.x == 3);
}
----
2.069.2: Compiles and passes asserts.
2.070.2, 2.071.0: "test.d(13): Error: struct test.RefCounted!().RefCounted.RefCountedStore.Impl no size yet for forward reference"
git master (bc74f4a): "test.d(14): Error: forward reference to (*this._store)._payload"
Comment #1 by ag0aep6g — 2016-05-10T22:02:59Z
Further reduced to two very similar, recently introduced ICEs: issue 16013.