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
- To: cxx-abi-dev@xxxxxxxxxxxxxxxx
- Subject: Re: [cxx-abi-dev] Deleted virtual functions
- From: David Vandevoorde <daveed@xxxxxxx>
- Date: Fri, 29 May 2009 11:21:56 -0400
<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On May 29, 2009, at 11:07 AM, Sean Perry wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><p>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.<br></p></div></blockquote><div><br></div><div>That thought crossed my mind, and then I dismissed it because __cxa_pure_virtual is already that way.</div><div><br></div><div>I think the API functions should keep C linkage, but the vtable should be allowed to point to a wrapper for these functions with C++ linkage.</div><div><br></div><div>Does that work?</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Daveed<br></div><div><br></div><br><blockquote type="cite"><div><p> <br> --<br> Sean Perry<br> Compiler Development<br> IBM Canada Lab<br> (905)-413-6031 (tie 313-6031), fax (905)-413-4839<br> <br> <span><graycol.gif></span>Dennis Handly <<a href="mailto:dhandly@xxxxxxxxxx">dhandly@xxxxxxxxxx</a>><br> <br> <br> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tbody><tr valign="top"><td style="background-image:url(cid:2__=0ABBFF56DFC106858f9e8a93df938@ca.ibm.com); background-repeat: no-repeat; " width="40%"> <ul> <ul> <ul> <ul><b><font size="2">Dennis Handly <<a href="mailto:dhandly@xxxxxxxxxx">dhandly@xxxxxxxxxx</a>></font></b><font size="2"> </font> <p><font size="2">05/28/2009 10:07 PM</font></p></ul> </ul> </ul> </ul> </td><td width="60%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tbody><tr valign="top"><td width="1%"><span><ecblank.gif></span><br> <div align="right"><font size="2">To</font></div></td><td width="100%"><span><ecblank.gif></span><br> <font size="2"><a href="mailto:jason@xxxxxxxxxx">jason@xxxxxxxxxx</a>, <a href="mailto:mark@xxxxxxxxxxxxxxxx">mark@xxxxxxxxxxxxxxxx</a></font></td></tr> <tr valign="top"><td width="1%"><span><ecblank.gif></span><br> <div align="right"><font size="2">cc</font></div></td><td width="100%"><span><ecblank.gif></span><br> <font size="2"><a href="mailto:cxx-abi-dev@xxxxxxxxxxxxxxxx">cxx-abi-dev@xxxxxxxxxxxxxxxx</a>, <a href="mailto:daveed@xxxxxxx">daveed@xxxxxxx</a></font></td></tr> <tr valign="top"><td width="1%"><span><ecblank.gif></span><br> <div align="right"><font size="2">Subject</font></div></td><td width="100%"><span><ecblank.gif></span><br> <font size="2">Re: [cxx-abi-dev] Deleted virtual functions</font></td></tr> </tbody></table> <table border="0" cellspacing="0" cellpadding="0"> <tbody><tr valign="top"><td width="58"><span><ecblank.gif></span></td><td width="336"><span><ecblank.gif></span></td></tr> </tbody></table> </td></tr> </tbody></table> <br> <tt>Looks good.<br> <br> >From: David Vandevoorde <<a href="mailto:daveed@xxxxxxx">daveed@xxxxxxx</a>><br> >I noticed that there isn't actually a requirement to point virtual <br> >table entried for pure virtual functions at __cxa_pure_virtual. Is <br> >that intentional or just sloppy wording?<br> <br> Well, why have __cxa_pure_virtual without using it? ;-)<br> <br> I have a suggestion for the signature for __cxa_pure_virtual and the new<br> __cxa_deleted_virtual:<br> <br> extern "C" void __cxa_deleted_virtual(void *this_ptr);<br> extern "C" void __cxa_pure_virtual(void *this_ptr);<br> <br> Where this_ptr can be cast to a dummy polymorphic class to get the class<br> name to print a nicer message:<br> <br> // A dummy polymorphic class to make typeid() do the work below.<br> class pv_dummy {<br> public:<br> virtual void dummy_func();<br> };<br> extern "C" {<br> extern void abort();<br> void __cxa_pure_virtual (void *this_ptr)<br> {<br> pv_dummy *obj = (pv_dummy*)this_ptr;<br> const char *mangled_name = typeid(*obj).name();<br> const char *demangled_name = abi::__cxa_demangle(mangled_name, 0, 0, 0);<br> if (!demangled_name) // out of space?<br> demangled_name = mangled_name;<br> fprintf(stderr, "aCC runtime: pure virtual function called for class \"%s\".<br> \n", demangled_name);<br> abort();<br> }<br> }<br> <br> --Apple-Mail-17--1051914877<br> filename=deleted_funcs.diffs<br> + <li>If C::f is a pure virtual function, the corresponding virtual table<br> + entry may point to __cxa_pure_virtual<br> <br> Did you want to explain why you used "may"?<br> Is this the case of declaring it pure but still having a definition?<br> (for the destructor)<br> </tt><br> </p></div></blockquote></div><br></body></html>