From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3FA2A385840D; Mon, 17 Apr 2023 14:27:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3FA2A385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681741637; bh=SJJAqlsmq3WKPQVlP6L53cb/G7ul5thCSHhQjl3CWek=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Rd9XiRgcLg0dqoG5tM1MfmyFHueSZZTzh2N7fiy6XvOwAxGBsLB7fhRe9PvyHnDgf 7GD7KiDhIWLmnXn3LWey7mO55XvottVrAG6Xpe+A24xQCTuHYrLJOoMfu+rEIp+EnD VZ3azIcUMQGKTmHJ5NDJh/hWMLioJaXiZb00hg6k= From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/105440] c++20: std::string's destructor not a constant expression when it should Date: Mon, 17 Apr 2023 14:27:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.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: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D105440 Patrick Palka changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org --- Comment #2 from Patrick Palka --- Seems this is ultimately an FE bug which is fixed by: diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index d1097764b10..9dbbf6eec03 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -3213,7 +3213,12 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, = tree t, && CLASS_TYPE_P (TREE_TYPE (res)) && !is_empty_class (TREE_TYPE (res))) if (replace_decl (&result, res, ctx->object)) - cacheable =3D false; + { + cacheable =3D false; + result =3D cxx_eval_constant_expression (ctx, result, lva= l, + non_constant_p, + overflow_p); + } } else /* Couldn't get a function copy to evaluate. */ In some cases we can simplify a call result further after replacing RESULT_= DECL with the current object under construction throughout the call result, which allows fold_binary_loc etc to later successfully fold comparisons involving= the call result such as _M_data() =3D=3D _M_local_data() in this case.=