Re: [cxx-abi-dev] Deleted virtual functions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cxx-abi-dev] Deleted virtual functions



The C linkage would be a problem on platforms that use a different calling.
The compiler is going to generate code that assumes the functions pointed
to by the virtual function table have C++ linkage.  These functions should
have C++ linkage too.

--
Sean Perry
Compiler Development
IBM Canada Lab
(905)-413-6031 (tie 313-6031), fax (905)-413-4839



                                                                       
             Dennis Handly                                             
             <dhandly@xxxxxxxx                                         
             om>                                                        To
                                       jason@xxxxxxxxxx,               
             05/28/2009 10:07          mark@xxxxxxxxxxxxxxxx           
             PM                                                         cc
                                       cxx-abi-dev@xxxxxxxxxxxxxxxx,   
                                       daveed@xxxxxxx                  
                                                                   Subject
                                       Re: [cxx-abi-dev] Deleted virtual
                                       functions                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       




Looks good.

>From: David Vandevoorde <daveed@xxxxxxx>
>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)

GIF image

GIF image

GIF image