From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8476A385EC54; Mon, 16 Aug 2021 10:22:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8476A385EC54 From: "tschwinge at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/101862] [C, C++] Potential '?:' diagnostic for always-true expressions in boolean context Date: Mon, 16 Aug 2021 10:22:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: tschwinge at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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 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: Mon, 16 Aug 2021 10:22:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101862 --- Comment #3 from Thomas Schwinge --- Thanks for your comments! (In reply to Andrew Macleod from comment #1) > I'm not sure exactly what you want to do. Neither am I! ;-) (Well, I do know "what", but not yet "how".) > The EVRP pass recognizes [...] > This seems to be too late to determine that a warning might be appropriat= e.. > and I'm not sure how you would figure that out from this IL. >=20 > We have to go way back before gimple before we see the conditional > expression. > The range machinery knows what you want to know, but IM not sure how you > could use it. Its only available once we go into SSA. Idea: preserve the original front end AST (or whatever is appropriate), for "potential diagnostics" ("delayed diagnostics"?), and then (re-)evaluate on= ce we have VR information (and whatever else is necessary). > we usually rejoice when we can fold asserts away :-) A classic case of tuning for code generation vs. diagnostics. ;-)=