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


--- Comment #0 from Brad Roberts <braddr puremagic.com> 2010-08-29 01:34:21 PDT
---
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


--- Comment #1 from Brad Roberts <braddr puremagic.com> 2010-08-30 00:39:15 PDT
---
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


--- Comment #2 from Rainer Schuetze <r.sagitario 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: -------
Aug 30 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4753



--- Comment #3 from Rainer Schuetze <r.sagitario gmx.de> 2010-08-31 00:14:49
PDT ---
(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. -- 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


--- Comment #4 from Don <clugdbug yahoo.com.au> 2010-09-08 05:07:39 PDT ---
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


--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2011-01-03
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