From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BF05A3951885; Wed, 24 Feb 2021 17:12:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF05A3951885 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99251] [11 Regression] inconsistent -Wnonnull warning behaviour with dynamic_cast Date: Wed, 24 Feb 2021 17:12:27 +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 X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: NEW 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: blocked cf_reconfirmed_on keywords short_desc everconfirmed cc bug_status 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: Wed, 24 Feb 2021 17:12:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99251 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |95507 Last reconfirmed| |2021-02-24 Keywords| |diagnostic Summary|Strange -Wnonnull warning |[11 Regression] |behaviour with dynamic_cast |inconsistent -Wnonnull | |warning behaviour with | |dynamic_cast Ever confirmed|0 |1 CC| |msebor at gcc dot gnu.org Status|UNCONFIRMED |NEW --- Comment #1 from Martin Sebor --- We discussed this instance of the warning in pr98646 and decided that even though issuing it for an access to the result of dynamic_cast was strictly a false positive when the operand was guaranteed to be nonnull by a prior tes= t, the workaround to cast to a reference rather than a pointer was simple enou= gh and made the intent clearer: return dynamic_cast(*p).i(); But the inconsistency exhibited in this test case is not a good thing (enclosing the cast in parentheses certainly shouldn't make a difference) a= nd suggests the decision should be revisited. The warning for the dynamic_cast should either be issued consistently or not at all. Let me look into it. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95507 [Bug 95507] [meta-bug] bogus/missing -Wnonnull=