On Sun, 13 Dec 2009 04:16:19 -0500, Frank Benoit <keinfarb...@googlemail.com> wrote:

casting an array of class references to an array of interface references
(or vice versa) will not work at runtime. Your program will crash.

This is because if the invisible pointer correction that is done if you
cast a single class ref to an interface ref.


C c = new C;
I i = c;

writefln( "c=%d i=%i", cast(uint)cast(void*)c, cast(uint)cast(void*)i);

This shows, the numeric values are not equal.
At the assignment were an imlicit cast is taking place, dmd inserts a
pointer adjustement. If you cast an array, nothing physically is done to
the array content. In fact you need to run a loop over the array and
cast each member on it own.

Thanks for informing me, my newer workaround avoids this problem.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Reply via email to