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.