https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96003
--- Comment #11 from Stephan Bergmann <sbergman at redhat dot com> --- (In reply to Martin Sebor from comment #10) > Patch for the static cast: > https://gcc.gnu.org/pipermail/gcc-patches/2020-July/550231.html LibreOffice runs into the same issue, but while the above patch fixes my first reduced test case > $ cat test1.cc > struct S1 {}; > struct S2: S1 {}; > struct S3: S1 {}; > struct S4: S2, S3 { void f(); }; > void g(S3 * p) { static_cast<S4 *>(p)->f(); } it does not fix the second > $ cat test2.cc > struct S1 { virtual ~S1(); }; > struct S2 { virtual ~S2(); }; > struct S3: S1, S2 { void f() const; }; > void g(S2 * p) { static_cast<S3 const *>(p)->f(); } > $ g++ -Wnonnull -fsyntax-only test2.cc > test2.cc: In function ‘void g(S2*)’: > test2.cc:4:48: warning: ‘this’ pointer null [-Wnonnull] > 4 | void g(S2 * p) { static_cast<S3 const *>(p)->f(); } > | ^ > test2.cc:3:26: note: in a call to non-static member function ‘void S3::f() > const’ > 3 | struct S3: S1, S2 { void f() const; }; > | ^