From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id A153A3857728; Fri, 22 Sep 2023 14:36:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A153A3857728 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695393394; bh=QxrKf2iEUJbhhFlCJbBkJFAMEWjR4wqx1QDWBcJo5Rk=; h=From:To:Subject:Date:From; b=N6n1xen+f8etPKZoyw/BfxKkJDkbOaTTIbC4t+qv6HNfKaL+E3pwAaGWkAEsPuYYm gNqcrnlOC2Pd8BRgOA0B1lrtIL2YAOnUpfw/PFM7nNVZohUW2OGcE4gsECUyvLmZW/ i5GF/xBeI7OVG+3FdEHZZnxcG7T0Qc6wzS4S1wiQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4231] c++ __integer_pack conversion again [PR111357] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 22cda0ca5fb406f22925bbf51ab152a958e3319d X-Git-Newrev: fd35d72a3dcd5ba14d81a1890236acd0145497e1 Message-Id: <20230922143634.A153A3857728@sourceware.org> Date: Fri, 22 Sep 2023 14:36:34 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fd35d72a3dcd5ba14d81a1890236acd0145497e1 commit r14-4231-gfd35d72a3dcd5ba14d81a1890236acd0145497e1 Author: Jason Merrill Date: Thu Sep 21 15:39:46 2023 +0100 c++ __integer_pack conversion again [PR111357] As Jakub pointed out, the real problem here is that in a partial substitution we're forgetting the conversion to the type of the non-type template argument, because maybe_convert_nontype_argument doesn't do anything with value-dependent arguments. I'm experimenting with changing that, but in the meantime we can work around it here. PR c++/111357 gcc/cp/ChangeLog: * pt.cc (expand_integer_pack): Use IMPLICIT_CONV_EXPR. Diff: --- gcc/cp/pt.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index ea5379098a5..73ac1cb597c 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -3769,6 +3769,13 @@ expand_integer_pack (tree call, tree args, tsubst_flags_t complain, { if (hi != ohi) { + /* Work around maybe_convert_nontype_argument not doing this for + dependent arguments. Don't use IMPLICIT_CONV_EXPR_NONTYPE_ARG + because that will make tsubst_copy_and_build ignore it. */ + tree type = tsubst (TREE_TYPE (ohi), args, complain, in_decl); + if (!TREE_TYPE (hi) || !same_type_p (type, TREE_TYPE (hi))) + hi = build1 (IMPLICIT_CONV_EXPR, type, hi); + call = copy_node (call); CALL_EXPR_ARG (call, 0) = hi; } @@ -3779,8 +3786,6 @@ expand_integer_pack (tree call, tree args, tsubst_flags_t complain, } else { - hi = perform_implicit_conversion_flags (integer_type_node, hi, complain, - LOOKUP_IMPLICIT); hi = instantiate_non_dependent_expr (hi, complain); hi = cxx_constant_value (hi, complain); int len = valid_constant_size_p (hi) ? tree_to_shwi (hi) : -1;