How immutable is an object's vptr?

Guillaume Piolat contact at spam.com
Sat Nov 11 12:54:44 UTC 2017


On Saturday, 11 November 2017 at 12:52:09 UTC, Johan Engelen 
wrote:
> Hi all,
>   I'm working on (basic) devirtualization, and am wondering how 
> immutable the vptr is in D. There is no clear spec on this.
> I am currently assuming that an object's vptr is completely 
> immutable and that use of the object after changes to its vptr 
> are UB (in contrast to the more complicated situation in C++).
>
> Please help me find an example where this assumption does not 
> hold.
>
> ```
> class A {
>   void foo();
> }

IIRC entry 0 of the vtable is for TypeInfo*, so at least casting 
and destruction won't work correctly.




More information about the Digitalmars-d mailing list