Skip to content

Commit

Permalink
fix Issue 18057 - [ICE] Segmentation fault (stack overflow) in Expres…
Browse files Browse the repository at this point in the history
…sion::ctfeInterpret()
  • Loading branch information
ibuclaw committed Jan 13, 2018
1 parent b1f6aec commit 265e42a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/dmd/aggregate.d
Expand Up @@ -459,7 +459,13 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
else if (vx._init)
{
assert(!vx._init.isVoidInitializer());
e = vx.getConstInitializer(false);
if (vx.inuse) // https://issues.dlang.org/show_bug.cgi?id=18057
{
vx.error(loc, "recursive initialization of field");
errors = true;
}
else
e = vx.getConstInitializer(false);
}
else
{
Expand Down
11 changes: 11 additions & 0 deletions test/compilable/interpret3.d
Expand Up @@ -7731,3 +7731,14 @@ bool foo17407()

static assert(!foo17407);

/**************************************************/
// https://issues.dlang.org/show_bug.cgi?id=18057
// Recursive field initializer causes segfault.

struct RBNode(T)
{
RBNode!T *copy = new RBNode!T;
}

static assert(!__traits(compiles, { alias bug18057 = RBNode!int; }));

0 comments on commit 265e42a

Please sign in to comment.