[cxx-abi-dev] Deleted virtual functions

Lawrence Crowl crowl at google.com
Fri May 29 19:01:22 UTC 2009


On 5/29/09, Mark Mitchell <mark at codesourcery.com> wrote:
> Dennis Handly wrote:
> > Well, why have __cxa_pure_virtual without using it?  ;-)
>
> I do not think it would be a good idea to require that a compiler
> put __cxa_pure_virtual into the virtual table.  For code-size
> optimization, having a simple NULL pointer is better.

Why is this a concern?  The tables are in .rodata and bounded by
the number of distinct classes, which is generally quite reasonable.

> (Note that some implementations of __cxa_pure_virtual call fprintf,
> and thereby drag in the whole I/O library; it's not just the
> cost of the __cxa_pure_virtual function itself.)  And in some
> environments, there may be better functions to call.
>
> I view __cxa_pure_virtual as a requirement on a conforming library,
> not on a conforming compiler.  The run-time library must provide
> this function, so that compilers that choose to use it can put
> it in the virtual table.  Therefore, I believe the current "may"
> wording is intentional and desirable.
>
> I also think that precedent should be followed for the new
> __cxa_deleted_virtual.  One advantage of that is that a compiler
> that wants to work with an older run-time library (i.e., one that
> does not contain __cxa_deleted_virtual) can use a NULL pointer.

I am not convinced that a new compiler will be able to use an old
library in general.  Explaining when it can and cannot use an old
library often causes more problems than it fixes.

-- 
Lawrence Crowl



More information about the cxx-abi-dev mailing list