www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4753] New: fail_compilation/fail116.d sends dmd into a loop, exhausting memory

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4753

           Summary: fail_compilation/fail116.d sends dmd into a loop,
                    exhausting memory
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: braddr puremagic.com



---
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);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4753


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression



---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4753


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

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



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: -------
Aug 30 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4753




PDT ---

 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 31 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4753


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



This was fixed by reverting svn 634. If the patch in bug 190 is re-used, this
patch here should be applied as well.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 08 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4753


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



00:35:14 PST ---
http://www.dsource.org/projects/dmd/changeset/842

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