public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "sbergman at redhat dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer Date: Thu, 27 May 2021 10:37:15 +0000 [thread overview] Message-ID: <bug-100797-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100797 Bug ID: 100797 Summary: using declaration causing virtual call with wrongly adjusted this pointer Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sbergman at redhat dot com Target Milestone: --- (I stripped this down from an issue found in LibreOffice, <https://git.libreoffice.org/core/+/0d3dd9d9f6f0e6236c8db8ebdea44c78854639a8%5E%21> "tdf#142467 crash on calling 'getInfoHelper' in final class", where the original code had the most derived class, S4 in the below stripped down example, marked as final, and where removing the "final" fixed things. In the below stripped down example, there is no difference in behavior whether or not S4 is marked final, but I hope the issue exposed by the stripped down example is still the same as the one originally experienced in the LibreOffice code.) At least with gcc-11.1.1-1.fc34.x86_64 and with a recent trunk build towards GCC 12: > $ cat test.cc > #include <iostream> > struct S1 { virtual ~S1() = default; }; > struct S2 { virtual void f1() = 0; }; > struct S3: S1, S2 { > void f1() { f2(); } > virtual void f2() = 0; > }; > struct S4: S3 { > void f2() { std::cout << "called\n"; } > using S2::f1; > }; > int main() { S4().f1(); } > $ g++ test.cc > $ ./a.out > Segmentation fault instead of printing "called". The issue goes away when removing the using S2::f1; declaration from S4.
next reply other threads:[~2021-05-27 10:37 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-27 10:37 sbergman at redhat dot com [this message] 2021-05-27 16:23 ` [Bug c++/100797] [9/10/11/12 Regression] " ppalka at gcc dot gnu.org 2021-05-27 16:25 ` ppalka at gcc dot gnu.org 2021-05-28 3:24 ` jason at gcc dot gnu.org 2021-05-28 9:23 ` cvs-commit at gcc dot gnu.org 2021-05-28 10:42 ` [Bug c++/100797] [10/11/12 " rguenth at gcc dot gnu.org 2021-05-28 12:58 ` cvs-commit at gcc dot gnu.org 2021-05-28 13:04 ` jason at gcc dot gnu.org 2021-05-31 6:26 ` sbergman at redhat dot com 2021-06-01 8:21 ` rguenth at gcc dot gnu.org 2021-06-01 8:43 ` [Bug c++/100797] [10/11 " rguenth at gcc dot gnu.org 2021-06-01 15:53 ` cvs-commit at gcc dot gnu.org 2021-06-01 15:53 ` cvs-commit at gcc dot gnu.org 2021-06-01 19:16 ` 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-100797-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).