From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 43CCA3893679; Fri, 5 Mar 2021 15:30:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43CCA3893679 From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99287] std::source_location::function_name breaks constexpr Date: Fri, 05 Mar 2021 15:30:56 +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: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to 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: Fri, 05 Mar 2021 15:30:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99287 Patrick Palka changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot g= nu.org Status|NEW |ASSIGNED --- Comment #3 from Patrick Palka --- IIUC, those two types are actually the same, it's just that one of them was obtained through the char_type alias, and it seems debug_tree prefers to sh= ow the name of the alias when the type came from one. It seems the issue ultimately is in cxx_eval_increment_expression: during evaluation of ++__first with __first =3D &"mystr"[n] + m and with lval=3Dfa= lse, since cxx_fold_pointer_plus_expression and not fold_build2 is responsible f= or simplifying this POINTER_PLUS_EXPR to &"mystr"[n+m], returning 'mod' actual= ly returns the unreduced &"mystr"[n] + m rather than the reduced &"mystr"[n+m] that we obtain as part of constexpr evaluation of the temporary MODIFY_EXPR= .=20 This unreduced return value of cxx_eval_increment interfers with later constexpr evaluation, e.g. folding of the POINTER_DIFF_EXPR. I'm testing the following which updates 'mod' with the result of evaluation= of the MODIFY_EXPR: --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5582,20 +5582,14 @@ cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t, /* Storing the modified value. */ tree store =3D build2_loc (cp_expr_loc_or_loc (t, input_location), MODIFY_EXPR, type, op, mod); - cxx_eval_constant_expression (ctx, store, - true, non_constant_p, overflow_p); + mod =3D cxx_eval_constant_expression (ctx, store, false, + non_constant_p, overflow_p); ggc_free (store); /* And the value of the expression. */=