[Issue 3569] DMD Stack Overflow with a struct member function inside a C-style struct initializer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 7 13:24:38 PDT 2010


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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #6 from Don <clugdbug at yahoo.com.au> 2010-06-07 13:24:35 PDT ---
The fact that struct initializers are evaluated at compile time is bug 3809;
only the stack overflow is unique to this bug.

Some tough cases for the test suite.
---
template Compileable(int z) { bool OK;}

struct Bug3569 {
    int bar() { return 7; }
}

struct Bug3569b {
    Bug3569 foo;
    void crash() {
        static assert(!is(typeof(Compileable!(foo.bar()))));
        static assert(!is(typeof(Compileable!((foo = Bug3569.init).bar()))));
    }
}

========
PATCH
Index: interpret.c
===================================================================
--- interpret.c    (revision 524)
+++ interpret.c    (working copy)
@@ -1110,8 +1110,9 @@

 Expression *ThisExp::interpret(InterState *istate)
 {
-    if (istate->localThis)
+    if (istate && istate->localThis)
         return istate->localThis->interpret(istate);
+    error("value of 'this' is not known at compile time");
     return EXP_CANT_INTERPRET;
 }

@@ -2105,6 +2106,11 @@
 #endif
     Expression *e = EXP_CANT_INTERPRET;
     Expression *e1 = this->e1;
+    if (!istate)
+    {
+        error("value of %s is not known at compile time", e1->toChars());
+        return e;
+    }

     if (fp)
     {

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