Skip to content

Commit

Permalink
fix Issue 4983 - [ICE] Stack overflow while initializing struct membe…
Browse files Browse the repository at this point in the history
…r with address of one of its methods
  • Loading branch information
9rnsr committed Nov 22, 2013
1 parent 7760a34 commit ea59491
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/mtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -6623,7 +6623,8 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc,
if (VarDeclaration *v = s->isVarDeclaration())
{
if (v && v->inuse && (!v->type || !v->type->deco)) // Bugzilla 9494
{ error(loc, "circular reference to '%s'", v->toPrettyChars());
{
error(loc, "circular reference to '%s'", v->toPrettyChars());
*pe = new ErrorExp();
return;
}
Expand Down Expand Up @@ -8059,7 +8060,8 @@ Expression *TypeStruct::dotExp(Scope *sc, Expression *e, Identifier *ident, int

VarDeclaration *v = s->isVarDeclaration();
if (v && v->inuse && (!v->type || !v->type->deco)) // Bugzilla 9494
{ e->error("circular reference to '%s'", v->toPrettyChars());
{
e->error("circular reference to '%s'", v->toPrettyChars());
return new ErrorExp();
}
if (v && !v->isDataseg() && (v->storage_class & STCmanifest))
Expand Down Expand Up @@ -8237,6 +8239,11 @@ Expression *TypeStruct::defaultInitLiteral(Loc loc)
{
VarDeclaration *vd = sym->fields[j];
Expression *e;
if (vd->inuse)
{
error(loc, "circular reference to '%s'", vd->toPrettyChars());
return new ErrorExp();
}
if (vd->offset < offset)
e = NULL;
else if (vd->init)
Expand Down Expand Up @@ -8705,7 +8712,8 @@ Expression *TypeClass::dotExp(Scope *sc, Expression *e, Identifier *ident, int f

VarDeclaration *v = s->isVarDeclaration();
if (v && v->inuse && (!v->type || !v->type->deco)) // Bugzilla 9494
{ e->error("circular reference to '%s'", v->toPrettyChars());
{
e->error("circular reference to '%s'", v->toPrettyChars());
return new ErrorExp();
}
if (v && !v->isDataseg() && (v->storage_class & STCmanifest))
Expand Down
15 changes: 15 additions & 0 deletions test/fail_compilation/ice4983.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice4983.d(14): Error: circular reference to 'ice4983.Foo.dg'
---
*/

struct Foo
{
void bar()
{
}

void delegate() dg = &Foo.init.bar;
}

0 comments on commit ea59491

Please sign in to comment.