From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 4CD763858C1F for ; Tue, 12 Sep 2023 17:50:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CD763858C1F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694541011; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=YDGuoL0y4mutUJlXfuRcwxP6akqRxzk9gZ1KOtVsNBY=; b=c3KVTN0h1YH5MPC5fUMfdRNFJ7mL2xvW9kk8AqPMz6cIdVBteIGCDRLzyWvvsccntEOd2P 0JC6l1ZXcX89mxSoaB4+iec5sq4kTeoMuiw5wJ/fKx5ZwUViuKvg2+FfzptAYZaKQLwi2M EgcMU9vRxMVsd4PJvC1joxglBN5dOjg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-131-XJtacD7GN_KiqgEbLTdqAw-1; Tue, 12 Sep 2023 13:50:08 -0400 X-MC-Unique: XJtacD7GN_KiqgEbLTdqAw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 448E093EC37 for ; Tue, 12 Sep 2023 17:50:08 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.225.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CE12340C6EBF; Tue, 12 Sep 2023 17:50:06 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 38CHnuMB3741331 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 19:50:01 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 38CHnp2i3741327; Tue, 12 Sep 2023 19:49:51 +0200 Date: Tue, 12 Sep 2023 19:49:46 +0200 From: Jakub Jelinek To: Marek Polacek Cc: Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: [pushed] c++: __integer_pack with class argument [PR111357] Message-ID: Reply-To: Jakub Jelinek References: <20230912172744.1930180-1-jason@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Sep 12, 2023 at 01:34:43PM -0400, Marek Polacek via Gcc-patches wrote: > On Tue, Sep 12, 2023 at 01:27:44PM -0400, Jason Merrill via Gcc-patches wrote: > > Tested x86_64-pc-linux-gnu, applying to trunk. > > > > -- 8< -- > > > > The argument might not already be an integer. > > > > PR c++/111357 > > > > gcc/cp/ChangeLog: > > > > * pt.cc (expand_integer_pack): Convert argument to int. > > > > gcc/testsuite/ChangeLog: > > > > * g++.dg/ext/integer-pack7.C: New test. > > --- > > gcc/cp/pt.cc | 2 ++ > > gcc/testsuite/g++.dg/ext/integer-pack7.C | 38 ++++++++++++++++++++++++ > > 2 files changed, 40 insertions(+) > > create mode 100644 gcc/testsuite/g++.dg/ext/integer-pack7.C > > > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > > index 838179d5fe3..b583c11eb99 100644 > > --- a/gcc/cp/pt.cc > > +++ b/gcc/cp/pt.cc > > @@ -3793,6 +3793,8 @@ expand_integer_pack (tree call, tree args, tsubst_flags_t complain, > > } > > else > > { > > + hi = perform_implicit_conversion_flags (integer_type_node, hi, complain, > > + LOOKUP_IMPLICIT); > > FWIW, we have perform_implicit_conversion for this. Is it correct to convert exactly to integer_type_node though? Consider #include using std::integer_sequence; using std::make_integer_sequence; template void g(integer_sequence) {} template struct c1 { static constexpr int value = 1; constexpr operator int() { return value; } constexpr operator long() { return value + 1; } }; template struct R { using S = make_integer_sequence{}>; R() noexcept(noexcept(g(S()))) {} }; int main() { R(); } Shouldn't that invoke c1{}.operator long() rather than operator int()? I thought the conversion was supposed to be done a few lines earlier, instead of doing CALL_EXPR_ARG (call, 0) = hi; do CALL_EXPR_ARG (call, 0) = perform_implicit_conversion_flags (TREE_TYPE (ohi), hi, complain, LOOKUP_IMPLICIT); or tsubst that TREE_TYPE (ohi) as well? I.e. convert to type of the template parameter. Jakub