From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ED5E6385EC57; Tue, 21 Jul 2020 19:27:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED5E6385EC57 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1595359650; bh=WnmXkbuKoKQOj20MEEWJ7F5P7WeqGO1aYYTRzHK5Tro=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EZ+SZpQnoI6cWOYKmCoYHm7nvAbnnbQsy8bn7lpapN7lSk/u5jzXAnbktvxn/cxw+ t8svS1CT1i0bQ2i0mbYBEvMAgQMG9oBVMaUws4dGEqyu4rYAGP0c9IY+/6J+ZOzX9H C/9dgyFX7A7BlWJw7YdKHV97eIbQhnVrWOE+S7fc= From: "sbergman at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96003] [11 Regression] spurious -Wnonnull calling a member on the result of static_cast Date: Tue, 21 Jul 2020 19:27:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: diagnostic, patch X-Bugzilla-Severity: normal X-Bugzilla-Who: sbergman at redhat dot com X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: Tue, 21 Jul 2020 19:27:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96003 --- Comment #11 from Stephan Bergmann --- (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 fi= rst 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(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(p)->f(); } > $ g++ -Wnonnull -fsyntax-only test2.cc > test2.cc: In function =E2=80=98void g(S2*)=E2=80=99: > test2.cc:4:48: warning: =E2=80=98this=E2=80=99 pointer null [-Wnonnull] > 4 | void g(S2 * p) { static_cast(p)->f(); } > | ^ > test2.cc:3:26: note: in a call to non-static member function =E2=80=98voi= d S3::f() const=E2=80=99 > 3 | struct S3: S1, S2 { void f() const; }; > | ^=