[Issue 3150] cast from dynamic array to ulong is allowed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 7 22:57:18 PDT 2010


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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|spec                        |accepts-invalid, patch
                 CC|                            |clugdbug at yahoo.com.au


--- Comment #1 from Don <clugdbug at yahoo.com.au> 2010-05-07 22:57:16 PDT ---
Although types other than ulong currently generate error messages, they should 
all be caught at the front end.

PATCH:
CastExp::semantic() in expression.c around line 7960 (DMD 2.045)

            if (tobn->isTypeBasic() && tobn->size() < t1bn->size())
                // Allow things like casting a long* to an int*
                ;
            else if (tobn->ty != Tvoid)
                // Cast to a pointer other than void*
                goto Lunsafe;
        }
        // BUG: Check for casting array types, such as void[] to int*[]
    }
+    if (fromtype->ty == Tarray && totype->ty != Tarray && totype->ty !=Tvoid)
+    {
+        error("Cannot cast %s of type %s to %s", e1->toChars(),
e1->type->toChars(), to->toChars());
+        return new ErrorExp();
+    }
    e = e1->castTo(sc, to);
    return e;
}

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