[Issue 10573] Weird linking problem with associative array cast [DMD 2.63]

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 8 13:56:39 PDT 2013


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



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-07-08 13:56:38 PDT ---
Btw, I'd be very careful using casts on hashes like that, there's no runtime
checking when you cast hashes, even if the key or value is a base class which
is casted to a derived class. For example:

-----
class A { }
class B : A { void call() { } }

void main()
{
    A[int] a;
    a[1] = new A();

    B[int] b = cast(B[int])a;  // unsafe, no exceptions thrown
    b[1].call();  // crash
}
-----

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