Segfault when casting array of Interface types

rcor via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 15 20:18:14 PDT 2014


On Tuesday, 16 September 2014 at 03:05:57 UTC, Franz wrote:
>> Your issue comme from auto.
>
> i is a I[]

I expected i to be an I[], but shouldn't a casting an element of 
an I[] to a C return either a C or null?

It is if I do this:
I[] i = [cast(I) new C, new D];
assert(cast(C) i[0]);  // fine

Come to think of it, the above will probably work in my situation.

But I still wonder why the first example doesn't work.


More information about the Digitalmars-d-learn mailing list