From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 323CB3858C2C; Fri, 22 Apr 2022 21:01:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 323CB3858C2C From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105321] [9/10/11 Regression] "non-constant condition" issued for function containing a short-circuited unevaluated non-constant expression Date: Fri, 22 Apr 2022 21:01:01 +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.2.1 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.5 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: Fri, 22 Apr 2022 21:01:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105321 --- Comment #9 from CVS Commits --- The releases/gcc-11 branch has been updated by Marek Polacek : https://gcc.gnu.org/g:afec66b054a7603ef394dc712ccbba37ae645fd9 commit r11-9930-gafec66b054a7603ef394dc712ccbba37ae645fd9 Author: Marek Polacek Date: Wed Apr 20 16:02:52 2022 -0400 c++: wrong error with constexpr COMPOUND_EXPR [PR105321] Here we issue a bogus error for the first assert in the test. Therein we have =3D (void) (VIEW_CONVERT_EXPR(yes) || handle_error ());, VIEW_CONVERT_EXPR(value); which has a COMPOUND_EXPR, so we get to cxx_eval_constant_expression . The problem here is that we call 7044 /* Check that the LHS is constant and then discard it.= */ 7045 cxx_eval_constant_expression (ctx, op0, 7046 true, non_constant_p, overflow_p, 7047 jump_target); where lval is always true, so the PARM_DECL 'yes' is not evaluated into its value. Fixed by always passing false for 'lval' in cxx_eval_logical_expression; there's no case where we actually expect an lvalue from a TRUTH_*. PR c++/105321 gcc/cp/ChangeLog: * constexpr.c (cxx_eval_logical_expression): Always pass false = for lval to cxx_eval_constant_expression. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-105321.C: New test. (cherry picked from commit 93b65ed9706e2ceb4be7b28c9ff9be759e68a614)=