From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2EDC03857830; Thu, 27 May 2021 10:37:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2EDC03857830 From: "sbergman at redhat dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sbergman at redhat dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 May 2021 10:37:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100797 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, "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 examp= le 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 > struct S1 { virtual ~S1() =3D default; }; > struct S2 { virtual void f1() =3D 0; }; > struct S3: S1, S2 { > void f1() { f2(); } > virtual void f2() =3D 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.=