typeid() broken for interfaces?

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Fri Nov 30 03:03:54 PST 2012


So the interfaces aren't supposed to hold a TypeInfo? That doesn't sound
right. That makes interfaces useless in a very large set of use cases.


On Fri, Nov 30, 2012 at 2:55 PM, Maxim Fomin <maxim at maxim-fomin.ru> wrote:

> On Friday, 30 November 2012 at 10:05:21 UTC, Gor Gyolchanyan wrote:
>
>> interface I { }
>> class C: I { }
>>
>> I object = new C;
>> assert(typeid(object) == typeid(C)); // fails
>>
>> Is this normal or is it a bug?
>> Note, that the same works fine in case of a base class, rather then an
>> interface.
>>
>
> It works according to spec. Object is expression of type interface I, so
> no dynamic type search is performed.
>



-- 
Bye,
Gor Gyolchanyan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121130/fa385df9/attachment.html>


More information about the Digitalmars-d mailing list