[dmd-internals] ClassInfo for C++ classes in DMD

Walter Bright via dmd-internals dmd-internals at puremagic.com
Thu Jul 7 13:10:53 PDT 2016



On 7/7/2016 5:43 AM, Jacob Carlborg wrote:
>
>> On 07 Jul 2016, at 12:23, Walter Bright via dmd-internals <dmd-internals at puremagic.com> wrote:
>>
>> C++ classes have no dynamic type info (i.e. what the most derived class is). But they do have static type info.
>
> What I mean is this:
>
> // first example, unrelated to the DMD codebase
>
> extern(C++) class Foo {}
>
> void main ()
> {
>     auto a = new Foo;
>     assert(a.classinfo is null);
> }
>
> // second example, somewhere inside the DMD codebase
>
> auto a = new IntegerExp(0);
> assert(a.classinfo !is null);
>
> Both of the above assertions pass. My question is why the second assertion pass.

I don't know. I suspect there is more to it than the snippet here.


More information about the dmd-internals mailing list