From: SF/projects/mingw n. l. <min...@li...> - 2012-11-23 15:27:26
|
Bugs item #3589217, was opened at 2012-11-22 16:11 Message generated for change (Comment added) made by earnie You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3589217&group_id=2435 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: gcc-4.7.0 Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: marksibly () Assigned to: Nobody/Anonymous (nobody) Summary: Bug with virtual methods and objects with dtors. Initial Comment: Mingw appears to have a bug involving multiple inheritance and virtual methods that return objects with dtors. I have tried on 3 ditros - nuwen, tdm and the official mingw distro - and it happens on all g++ versions >= 4.7.0. It does not appear to occur on Linux, although I've only been able to test with kubuntu12 and mint14, both of which have g++ 4.7.2 installed. Anyway, see below code: The problem occurs when the 'interface method' LinkResolver is called by the markdown object. The correct method is invoked, but the 'this' pointer is messed up. The trigger seems to be the String dtor. Remove this, or have the interface method return a simple type, and it works as expected. #include <stdio.h> struct String { ~String() { } }; struct Object { virtual ~Object() { } }; struct LinkResolver { virtual String ResolveLink() = 0; }; struct Docs : public Object, public virtual LinkResolver { Docs() { printf(" Docs::Docs() this: %p\n", this); } virtual String ResolveLink() { printf("Docs::ResolveLink() this: %p\n", this); return String(); } }; struct Markdown { LinkResolver * _resolver; Markdown(LinkResolver * resolver) : _resolver(resolver) { } void Go() { _resolver->ResolveLink(); } }; int main() { printf("GCC %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); Docs d; printf(" main() &d: %p\n", &d); d.ResolveLink(); Markdown m(&d); m.Go(); } ---------------------------------------------------------------------- >Comment By: Earnie Boyd (earnie) Date: 2012-11-23 07:27 Message: Please report his to the GCC bug tracker. See http://gcc.gnu.org/bugs for information on how to do that. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3589217&group_id=2435 |