[Issue 4753] fail_compilation/fail116.d sends dmd into a loop, exhausting memory

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 30 15:16:12 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4753


Rainer Schuetze <r.sagitario at gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario at gmx.de


--- Comment #2 from Rainer Schuetze <r.sagitario at gmx.de> 2010-08-30 15:15:59 PDT ---
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();

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list