fix Issue 23574 - ICE: AssertError@src/dmd/optimize.d(866): Assertion failure (#14736)

This commit is contained in:
Iain Buclaw 2022-12-23 08:51:17 +01:00 committed by GitHub
parent 89551057e6
commit 9b4c82e516
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View file

@ -862,7 +862,8 @@ Expression Expression_optimize(Expression e, int result, bool keepLvalue)
return returnE_e1(); // 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);
if (cdfrom.size(e.loc) == SIZE_INVALID)
return error();
assert(cdfrom.sizeok == Sizeok.done);
assert(cdto.sizeok == Sizeok.done || !cdto.isBaseOf(cdfrom, null));
int offset;

View file

@ -0,0 +1,41 @@
// https://issues.dlang.org/show_bug.cgi?id=23574
/*
TEST_OUTPUT:
---
fail_compilation/fail23574.d(26): Error: function `object._xopEquals` has no `return` statement, but is expected to return a value of type `bool`
Error: undefined identifier `size_t` in module `object`
fail_compilation/fail23574.d(34): Error: template instance `object.S17915!(MyClass)` error instantiating
fail_compilation/fail23574.d(30): Error: function `object.SDL_GetKeyName` has no `return` statement, but is expected to return a value of type `const(char)`
---
*/
module object;
class Object
{
}
bool opEquals(LHS, RHS)(LHS lhs, RHS)
{
opEquals(cast()lhs);
}
class TypeInfo
{
}
bool _xopEquals()
{
}
const(char)SDL_GetKeyName()
{
class MyClass
{
S17915!MyClass m_member;
}
}
struct S17915(T)
{
T owner;
}