[Issue 4072] New: Stack overflow on recursive template expansion inside contract

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 8 06:18:06 PDT 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 at puremagic.com
        ReportedBy: clugdbug at yahoo.com.au


--- Comment #0 from Don <clugdbug at 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: -------


More information about the Digitalmars-d-bugs mailing list