[cxx-abi-dev] Deleted virtual functions

David Vandevoorde daveed at edg.com
Fri May 29 02:55:57 UTC 2009


On May 28, 2009, at 10:07 PM, Dennis Handly wrote:

> Looks good.
>
>> From: David Vandevoorde <daveed at edg.com>
>> I noticed that there isn't actually a requirement to point virtual
>> table entried for pure virtual functions at __cxa_pure_virtual.  Is
>> that intentional or just sloppy wording?
>
> Well, why have __cxa_pure_virtual without using it?  ;-)


I was wondering about that.  Maybe if a pure virtual function has an  
implementation one could call that implementation?


> I have a suggestion for the signature for __cxa_pure_virtual and the  
> new
> __cxa_deleted_virtual:
>
> extern "C" void __cxa_deleted_virtual(void *this_ptr);
> extern "C" void __cxa_pure_virtual(void *this_ptr);
>
> Where this_ptr can be cast to a dummy polymorphic class to get the  
> class
> name to print a nicer message:
>
> // A dummy polymorphic class to make typeid() do the work below.
> class pv_dummy {
> public:
>    virtual void dummy_func();
> };
> extern "C" {
> extern void abort();
> void __cxa_pure_virtual (void *this_ptr)
> {
>    pv_dummy *obj = (pv_dummy*)this_ptr;
>    const char *mangled_name = typeid(*obj).name();
>    const char *demangled_name = abi::__cxa_demangle(mangled_name, 0,  
> 0, 0);
>    if (!demangled_name)  // out of space?
>        demangled_name = mangled_name;
>    fprintf(stderr, "aCC runtime: pure virtual function called for  
> class \"%s\".
> \n", demangled_name);
>    abort();
> }
> }


Nice!  But would that break backward compatibility?


>
> --Apple-Mail-17--1051914877
> 	filename=deleted_funcs.diffs
> + <li>If C::f is a pure virtual function, the corresponding virtual  
> table
> + entry may point to __cxa_pure_virtual
>
> Did you want to explain why you used "may"?


That's what I was referring to: The existing text didn't require  
entries corresponding to pure virtual functions to point to  
__cxa_pure_virtual.  So I left that uncertainty in the words I added.


> Is this the case of declaring it pure but still having a definition?
> (for the destructor)


I don't know, unfortunately.  I think I attended all the meetings and  
read all the mailing list discussions, but it doesn't ring a bell.

	Daveed




More information about the cxx-abi-dev mailing list