public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "zhezherun at yandex dot ru" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base Date: Mon, 28 Nov 2011 12:18:00 -0000 [thread overview] Message-ID: <bug-51331-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51331 Bug #: 51331 Summary: bad code generated when explicitly calling auto-generated constructor of virtual base Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: zhezherun@yandex.ru If a virtual base class has an auto-generated default constructor, explicitly calling it from the derived class' constructor can result in bad code. The following stripped-down example reproduces the issue: #include <iostream> struct A { A(): x(10) {} virtual ~A() {} int x; }; struct B: public virtual A { }; struct C: public virtual A { }; struct D: public B, virtual public C { D(): B(), C() {} // note an explicit call to C() which is auto-generated }; int main() { D* d = new D(); std::cout << d->x << std::endl; // Crashes here with the following message: // *** glibc detected *** ./test: free(): invalid next size (fast) delete d; } This code used to work correctly in gcc 4.1.2 but crashes in gcc 4.6.2 on i386 (both -m32 and -m64).
next reply other threads:[~2011-11-28 11:51 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-11-28 12:18 zhezherun at yandex dot ru [this message] 2011-11-29 5:28 ` [Bug c++/51331] " pinskia at gcc dot gnu.org 2011-11-29 10:09 ` zhezherun at yandex dot ru 2011-11-29 13:11 ` paolo.carlini at oracle dot com 2011-12-14 23:40 ` [Bug c++/51331] [4.6/4.7 Regression] " pinskia at gcc dot gnu.org 2011-12-16 18:59 ` jason at gcc dot gnu.org 2011-12-16 22:35 ` jason at gcc dot gnu.org 2011-12-16 23:01 ` jason at gcc dot gnu.org 2011-12-16 23:03 ` jason 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-51331-4@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).