[Issue 2399] ICE(cgcod.c) on casting function to delegate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 15 14:35:47 PDT 2009


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


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

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




--- Comment #3 from Don <clugdbug at yahoo.com.au>  2009-05-15 14:35:46 PDT ---
The root cause is in cast.c, 
Expression *SymOffExp::castTo(Scope *sc, Type *t).
Casting from a function pointer to a delegate must be forbidden.
This patch also fixes Bug 2875.


============
   else if (tb->ty == Tdelegate && f->isNested())
    {
    e = new DelegateExp(loc, new IntegerExp(0), f);
    e = e->semantic(sc);
   } 
+    else if (tb->ty == Tdelegate) {
+    error("Cannot cast from function pointer to delegate");
+        return this;
+   }
    else
    {
    e = new SymOffExp(loc, f, 0);
    e->type = t;
    }

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