public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55453] New: Bug with virtual methods and objects with dtors.
@ 2012-11-23 20:42 blitzmunter at gmail dot com
  2012-11-23 21:45 ` [Bug c++/55453] " paolo.carlini at oracle dot com
  2012-11-23 21:51 ` paolo.carlini at oracle dot com
  0 siblings, 2 replies; 3+ messages in thread
From: blitzmunter at gmail dot com @ 2012-11-23 20:42 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55453

             Bug #: 55453
           Summary: Bug with virtual methods and objects with dtors.
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: blitzmunter@gmail.com


Hi,

Mingw G++ 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.

Even though this appears to be mingw specific, I've already posted this bug
report on the mingw bug reports system and they told me to post it here.

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.

Bye!
Mark

//***** CODE ******

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/55453] Bug with virtual methods and objects with dtors.
  2012-11-23 20:42 [Bug c++/55453] New: Bug with virtual methods and objects with dtors blitzmunter at gmail dot com
@ 2012-11-23 21:45 ` paolo.carlini at oracle dot com
  2012-11-23 21:51 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-23 21:45 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55453

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-23 21:44:57 UTC ---
target/55171 ? (and we may already have yet another related issue)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/55453] Bug with virtual methods and objects with dtors.
  2012-11-23 20:42 [Bug c++/55453] New: Bug with virtual methods and objects with dtors blitzmunter at gmail dot com
  2012-11-23 21:45 ` [Bug c++/55453] " paolo.carlini at oracle dot com
@ 2012-11-23 21:51 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-23 21:51 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55453

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |ktietz at gcc dot gnu.org
         Resolution|                            |DUPLICATE

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-23 21:51:10 UTC ---
Yes, c++/55367. Kai, could you please double check this?

*** This bug has been marked as a duplicate of bug 55367 ***


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-23 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-23 20:42 [Bug c++/55453] New: Bug with virtual methods and objects with dtors blitzmunter at gmail dot com
2012-11-23 21:45 ` [Bug c++/55453] " paolo.carlini at oracle dot com
2012-11-23 21:51 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).