public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "antonio.poggiali at datalogic dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/66666] ARM compiled code segmentation fault on multiple inheritance Date: Fri, 26 Jun 2015 11:23:00 -0000 [thread overview] Message-ID: <bug-66666-4-kKPN480YIe@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-66666-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66666 --- Comment #3 from Antonio Poggiali <antonio.poggiali at datalogic dot com> --- I've understand a little better the problem. The compiler passes to std::list copy constructor a different address respect to the destination variable. This causes size() call to fail (endless loop or segmentation fault). Here you can find a simpler test-bench: #include <iostream> using namespace std; class TestReference { public: // This is a pointer to me const TestReference * _me; TestReference() { _me = this; } TestReference(const TestReference &obj) { _me = this; } }; class SmartObject { public: SmartObject(){} // removing this destructor makes it work virtual ~SmartObject(){} }; class IMyInterface { public: IMyInterface(){} // removing this destructor have no effect (fails anyway) virtual ~IMyInterface(){} virtual TestReference getTestReference() = 0; }; // inheriting SmartObject virtually makes it work (but it is not feasible on the overall application architecture) class MyObject : public virtual IMyInterface, public SmartObject { public: MyObject() : IMyInterface(), SmartObject() {} virtual TestReference getTestReference() { return testReference; } virtual ~MyObject(){ } TestReference testReference; }; int main() { IMyInterface *ip = new MyObject(); TestReference TestReference_local; std::cout << "object address " << &TestReference_local << std::endl; std::cout << "object address in constructor " << TestReference_local._me << std::endl; if (&TestReference_local != TestReference_local._me) std::cout << "warning! addresses are different!" << std::endl; TestReference TestReference_clone = ip->getTestReference(); std::cout << "object address " << &TestReference_clone << std::endl; std::cout << "object address in copy constructor " << TestReference_clone._me << std::endl; if (&TestReference_clone != TestReference_clone._me) std::cout << "warning! addresses are different!" << std::endl; delete ip; return 0; } Basically I expect the object address in the copy constructor (this) to be the same of the object in the calling code, but when the program fails it is not so!
next prev parent reply other threads:[~2015-06-26 11:23 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-06-25 13:10 [Bug c++/66666] New: " antonio.poggiali at datalogic dot com 2015-06-25 17:49 ` [Bug c++/66666] " ramana at gcc dot gnu.org 2015-06-26 7:04 ` antonio.poggiali at datalogic dot com 2015-06-26 11:23 ` antonio.poggiali at datalogic dot com [this message] 2015-06-26 11:24 ` antonio.poggiali at datalogic dot com 2015-06-27 12:42 ` [Bug c++/66666] ARM wrong copy constructor address " mikpelinux at gmail dot com 2015-06-28 12:40 ` mikpelinux at gmail dot com 2015-06-29 15:56 ` antonio.poggiali at datalogic dot com 2015-06-29 15:59 ` antonio.poggiali at datalogic dot com 2015-06-30 7:01 ` antonio.poggiali at datalogic dot com 2015-06-30 13:24 ` antonio.poggiali at datalogic dot com 2015-06-30 17:09 ` jgreenhalgh at gcc dot gnu.org 2015-07-01 10:18 ` jgreenhalgh at gcc dot gnu.org 2015-07-01 10:26 ` antonio.poggiali at datalogic dot com 2015-07-03 15:57 ` jgreenhalgh at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-66666-4-kKPN480YIe@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).