Bug 4753 – fail_compilation/fail116.d sends dmd into a loop, exhausting memory

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-29T01:34:00Z
Last change time
2011-01-03T00:35:14Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
braddr
Blocks
3979

Comments

Comment #0 by braddr — 2010-08-29T01:34:21Z
make test_results/fail_compilation/fail116.d.out The source points to fixed bug 405. The code: // 405 template square(typeof(x) x) { const square = x * x; } const b = square!(1.2);
Comment #1 by braddr — 2010-08-30T00:39:15Z
Flagging as a regression. r634 introduced it: This block of the diff is where dmd goes recursive: @@ -4215,6 +4215,9 @@ Expression *VarExp::semantic(Scope *sc) #endif } + if (type && !type->deco) + type = type->semantic(loc, sc); + /* Fix for 1161 doesn't work because it causes protection * problems when instantiating imported templates passing private * variables as alias template parameters.
Comment #2 by r.sagitario — 2010-08-30T15:15:59Z
TypeTypeof should have a recursion check similar to TypeFunction and TypeTypedef. The test case compiles with the following patch, without reverting r634. Index: mtype.c =================================================================== --- mtype.c (revision 638) +++ mtype.c (working copy) @@ -5866,6 +5866,7 @@ TypeTypeof::TypeTypeof(Loc loc, Expression *exp) : TypeQualified(Ttypeof, loc) { + inuse = 0; this->exp = exp; } @@ -5909,6 +5910,13 @@ //printf("TypeTypeof::semantic() %p\n", this); //static int nest; if (++nest == 50) *(char*)0=0; + if (inuse) + { + inuse = 2; + error(loc, "circular typeof definition"); + return Type::terror; + } + inuse++; #if 0 /* Special case for typeof(this) and typeof(super) since both @@ -6010,9 +6018,11 @@ goto Lerr; } } + inuse--; return t; Lerr: + inuse--; return tvoid; // should this be Type::terror? } Index: mtype.h =================================================================== --- mtype.h (revision 638) +++ mtype.h (working copy) @@ -659,6 +659,7 @@ struct TypeTypeof : TypeQualified { Expression *exp; + int inuse; TypeTypeof(Loc loc, Expression *exp); Type *syntaxCopy();
Comment #3 by r.sagitario — 2010-08-31T00:14:49Z
(In reply to comment #2) > The test case compiles with the following patch, without reverting > r634. I meant "as expected fails to compile with error message and without segfault", of course.
Comment #4 by clugdbug — 2010-09-08T05:07:39Z
This was fixed by reverting svn 634. If the patch in bug 190 is re-used, this patch here should be applied as well.
Comment #5 by bugzilla — 2011-01-03T00:35:14Z