From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ED9B03858D32; Tue, 5 Sep 2023 09:55:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED9B03858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693907718; bh=mBZbY+4bIZlUOiXYZjU20CCfgwBO/rpqEWXhcSOY5Ig=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FlUPw4eAxYk+YlZi3vX11cle2unoIMN2fRyS+pJrq8rDDrJUy5rouyMHdAPFo8eXq iwY0TUOFTotRgov6WWy13c19cMGF3vLXWB/dEjEFMI5ctzqL5CusenCsxnLZc2QNkQ aSC+NL8Ha7FqGt0jS8/8axo7G7FYUFqdy7nucYII= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111281] unhelpful warning output ('nonnull' argument 'v' compared to NULL) Date: Tue, 05 Sep 2023 09:55:18 +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: 12.2.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: redi 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111281 --- Comment #7 from Jonathan Wakely --- The warning comes from the middle end, where the context of the conversion = to bool might have been lost. But the C++ front end already suppresses those warnings in several places: /* This is a compiler generated comparison, don't emit e.g. -Wnonnull-compare warning for it. */ else if (TREE_CODE (ifexp) =3D=3D NE_EXPR) suppress_warning (ifexp, OPT_Wnonnull_compare); Maybe we want that when implicitly converting a function to bool, but then = we wouldn't get any warning at all. It does seem useful to warn about converti= ng a non-weak function to bool, because it's always true so why not just write `true` instead. But maybe we want a C++ FE warning instead of the middle end one.=