Thread overview
[Issue 4072] New: Stack overflow on recursive template expansion inside contract
Apr 08, 2010
Don
Apr 08, 2010
Walter Bright
Apr 09, 2010
Don
April 08, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4072

           Summary: Stack overflow on recursive template expansion inside
                    contract
           Product: D
           Version: 2.040
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-invalid-code, patch
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


--- Comment #0 from Don <clugdbug@yahoo.com.au> 2010-04-08 06:18:01 PDT ---
void bug4072(T)(T x)
   if (is(typeof(bug4072(x))))
{}

static assert(!is(typeof(bug4072(7))));

-----
PATCH:

template.c line 1421.
-----------------------------------
        Objects dedargs;
+        static int nest = 0;
+        if (++nest > 300)
+        {
+            global.gag = 0;            // ensure error message gets printed
+            error("recursive expansion");
+            if (sc->tinst) sc->tinst->printInstantiationTrace();
+            fatal();
+        }
        m = td->deduceFunctionTemplateMatch(loc, targsi, ethis, fargs,
&dedargs);
+        --nest;
        //printf("deduceFunctionTemplateMatch = %d\n", m);
        if (!m)                 // if no match
            continue;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4072


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2010-04-08 13:59:47 PDT ---
changeset 432

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 09, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4072


Don <clugdbug@yahoo.com.au> changed:

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


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-04-09 13:43:37 PDT ---
Fixed DMD2.043.

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