On 8/12/15 11:46 PM, rsw0x wrote:
Sample code:

class C{}
struct S{}

void main(){
     import std.stdio;
     auto c = new shared C();
     auto s = new shared S();
     writeln(typeid(c)); //modulename.C
     writeln(typeid(s)); //shared(modulename.S)*
     writeln(typeid(c).next); //null
     writeln(typeid(s).next); //shared(modulename.S)
     writeln(typeid(typeid(s).next) is typeid(TypeInfo_Shared)); //true
     writeln(typeid(typeid(c)) is typeid(TypeInfo_Shared)); //false
}


What's the reason that the shared propagates to the typeinfo for the
struct, but not for the class declaration?

That is definitely a bug. It's because typeid is looking up the derived type via the vtable, but the compiler should rewrap it with 'shared' afterwards.

This is enough to make me think it's a bug:

class C{}

void main(){
    auto c1 = new C;
    auto c2 = new shared(C);
    assert(typeid(c1) is typeid(c2));
    assert(!is(typeof(c1) == typeof(c2)));
    pragma(msg, typeof(c1)); // C
    pragma(msg, typeof(c2)); // shared(C)
}

I don't think it's shared-specific.

-Steve

Reply via email to