If compiled with -O, this generates wrong code instead. Also applies to D1.
Comment #2 by clugdbug — 2009-05-15T00:30:01Z
Internal error: ..\backend\cgcod.c 1549
This is almost certainly related to bug 2323, bug 2672, and bug 2875.
Comment #3 by clugdbug — 2009-05-15T14:35:46Z
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;
}