[Issue 3432] ICE(e2ir.c): casting template expression

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 22 01:35:54 PDT 2009


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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Version|2.036                       |1.00
            Summary|ICE(e2ir.c): casting local  |ICE(e2ir.c): casting
                   |template function           |template expression


--- Comment #2 from Don <clugdbug at yahoo.com.au> 2009-10-22 01:35:53 PDT ---
Applies to D1 as well. Doesn't require nested templates. Test case (ICEs even
on DMD0.175):
---
void fun(T=int)(int w, int z) {}

void main() {
    auto x = cast(void function(int, int))fun;
}
---
Root cause: Shouldn't be able to cast from void to anything else (except void).

This patch also moves some error messages from e2ir into the front-end where
they belong.

-----
PATCH: expression.c, line 7423 (DMD 2.035, svn rev215):

    if (!to->equals(e1->type))
    {
        e = op_overload(sc);
        if (e)
        {
        return e->implicitCastTo(sc, to);
        }
+        /* Cannot cast from void to anything other than void
+         */
+        if (e1->type == Type::tvoid) {
+        error("'%s' is void and cannot be cast to %s", e1->toChars(),
to->toChars());
+        return new ErrorExp();
+        }
    }

    Type *t1b = e1->type->toBasetype();
    Type *tob = to->toBasetype();

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