Skip to content

Commit

Permalink
fix Issue 17915 - [REG 2.073] core.exception.AssertError@ddmd/optimiz…
Browse files Browse the repository at this point in the history
…e.d(614): Assertion failure
  • Loading branch information
WalterBright committed Nov 2, 2017
1 parent 3c2d007 commit dd2fcfa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ddmd/optimize.d
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ extern (C++) Expression Expression_optimize(Expression e, int result, bool keepL
// See if we can remove an unnecessary cast
ClassDeclaration cdfrom = e.e1.type.isClassHandle();
ClassDeclaration cdto = e.type.isClassHandle();
if (cdto == ClassDeclaration.object && !cdfrom.isInterfaceDeclaration())
goto L1; // can always convert a class to Object
// Need to determine correct offset before optimizing away the cast.
// https://issues.dlang.org/show_bug.cgi?id=16980
cdfrom.size(e.loc);
Expand Down
17 changes: 17 additions & 0 deletions test/runnable/xtest46.d
Original file line number Diff line number Diff line change
Expand Up @@ -7942,6 +7942,22 @@ void test17349()
assert(i == 2);
}

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

void test17915()
{
static class MyClass
{
S17915!MyClass m_member;
}
}

struct S17915(T)
{
T owner;
}

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

int main()
Expand Down Expand Up @@ -8262,6 +8278,7 @@ int main()
test16466();
test16408();
test17349();
test17915();

printf("Success\n");
return 0;
Expand Down

0 comments on commit dd2fcfa

Please sign in to comment.