Showing with 49 additions and 4 deletions.
  1. +2 −0 src/clone.c
  2. +4 −2 src/todt.c
  3. +33 −1 test/runnable/aliasthis.d
  4. +10 −1 test/runnable/testdt.d
2 changes: 2 additions & 0 deletions src/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ bool needOpEquals(StructDeclaration *sd)
TypeStruct *ts = (TypeStruct *)tv;
if (needOpEquals(ts->sym))
goto Lneed;
if (ts->sym->aliasthis) // Bugzilla 14806
goto Lneed;
}
}
Ldontneed:
Expand Down
6 changes: 4 additions & 2 deletions src/todt.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,13 @@ dt_t **Expression_toDt(Expression *e, dt_t **pdt)
pdt = dtnzeros(pdt, vd->offset - offset);
e = (*se->elements)[k];

dt_t *dt = NULL;
Type *tb = vd->type->toBasetype();
if (tb->ty == Tsarray)
toDtElem(((TypeSArray *)tb), pdt, e);
toDtElem(((TypeSArray *)tb), &dt, e);
else
Expression_toDt(e, pdt); // convert e to an initializer dt
Expression_toDt(e, &dt); // convert e to an initializer dt
pdt = dtcat(pdt, dt);

offset = vd->offset + vd->type->size();
}
Expand Down
34 changes: 33 additions & 1 deletion test/runnable/aliasthis.d
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,10 @@ struct RefCounted12008(T)
return 0;
}

int refCountedPayload() inout;
int refCountedPayload() inout
{
return 0;
}

alias refCountedPayload this;
}
Expand Down Expand Up @@ -1802,6 +1805,34 @@ void test13009()
alias ISput = IS .put;
}

/***************************************************/
// 14806

struct Nullable14806
{
float get() { return float.nan; }
alias get this;
}

struct Foo14806(T)
{
T bar;
Nullable14806 baz;
}

void test14806()
{
Foo14806!int a, b;
assert(a != b);
// ==> a.tupleof != b.tupleof
// ==> a.bar != b.bar || a.baz.get() != b.baz.get()

Foo14806!string c, d;
assert(c != d);
// ==> c.tupleof != d.tupleof
// ==> c.bar != d.bar || c.baz.get() != d.baz.get()
}

/***************************************************/

int main()
Expand Down Expand Up @@ -1857,6 +1888,7 @@ int main()
test11800();
test13490();
test11355();
test14806();

printf("Success\n");
return 0;
Expand Down
11 changes: 10 additions & 1 deletion test/runnable/testdt.d
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void test13505()
// 14699

struct S14699a { ubyte[0][10] values; }
struct S14699b { S14699a tbl; }
struct S14699b { S14699a tbl; }
// +/

ubyte[0][1] sa14699;
Expand All @@ -87,6 +87,15 @@ void test14699()
//auto p = &sa14699; // Cannot work in Win32 (OMF)
}

/******************************************/
// 14805

struct S14805
{
ushort one;
}
auto a14805 = new S14805[513*513];

/******************************************/

int main()
Expand Down