Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 8179 - ICE(e2ir.c) with failed fixed size array cast #2638

Merged
merged 1 commit into from
Oct 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/cast.c
Expand Up @@ -1207,7 +1207,7 @@ Expression *ComplexExp::castTo(Scope *sc, Type *t)

Expression *NullExp::castTo(Scope *sc, Type *t)
{
//printf("NullExp::castTo(t = %p)\n", t);
//printf("NullExp::castTo(t = %s) %s\n", t->toChars(), toChars());
if (type->equals(t))
{
committed = 1;
Expand Down Expand Up @@ -1250,6 +1250,10 @@ Expression *NullExp::castTo(Scope *sc, Type *t)
return e->Expression::castTo(sc, t);
}
#endif
if (tb->ty == Tsarray || tb->ty == Tstruct)
{
error("cannot cast null to %s", t->toChars());
}
e->type = t;
return e;
}
Expand Down
11 changes: 11 additions & 0 deletions test/fail_compilation/fail8179.d
@@ -0,0 +1,11 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail8179.d(10): Error: cannot cast null to int[2]
---
*/
void main()
{
int[2] a;
a = cast(int[2])null;
}