[cxx-abi-dev] Deleted virtual functions

Dennis Handly dhandly at cup.hp.com
Fri May 29 02:07:57 UTC 2009


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 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();
}
}

--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"?
Is this the case of declaring it pure but still having a definition?
(for the destructor)



More information about the cxx-abi-dev mailing list