[cxx-abi-dev] Deleted virtual functions

Mark Mitchell mark at codesourcery.com
Fri May 29 15:22:14 UTC 2009


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.  (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.

-- 
Mark Mitchell
CodeSourcery
mark at codesourcery.com
(650) 331-3385 x713



More information about the cxx-abi-dev mailing list