C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Give Microsoft N years to change their ABI

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 14 Nov 2024 13:36:56 +0000
On Thu, Nov 14, 2024 at 1:20 PM Lénárd Szolnoki wrote:
>
> On 14 November 2024 13:15:54 GMT, Egor wrote:
> >
> > If I'm not mistaken, multiple inheritance can cause the vtable to be
> > at a non-zero offset on all compilers (if the first base isn't polymorphic).
>
> AFAIK Itanium reorders the bases in this case. But if you have multiple
> polymorphic bases, then one of the vtable pointers is surely not at offset 0.


I'm open to correction here but I've never seen any compiler -- other
than the Microsoft one -- put the VTable pointer anywhere other than
offset 0, even in complex cases of multiple and/or virtual
inheritance. So if you can come up with a class hierarchy that does
so, please post the class definitions here and we'll investigate it.

It's the Microsoft compiler that prevents us from writing the
following two functions:

void const *GetMostDerivedObject(void const *const arg)
{
    return dynamic_cast<void*>(arg);
}

std::type_info const &GetMostDerivedTypeInfo(void const *const arg)
{
    return typeid( *dynamic_cast<void*>(arg) ); // you catch my drift here
}

Received on 2024-11-14 13:37:08