From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 7B345385115F for ; Fri, 26 Aug 2022 18:22:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7B345385115F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 432D9336C8; Fri, 26 Aug 2022 18:22:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661538156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6G+fwE7qD46Hvx3slwj0sYknw2MfICjxdDcUgNjYMlY=; b=SCvZExWkdcV0WWV679hlQ/fMtR3o7W8zhDDL1u+R3k68vBceCj9H4DIQvY+MTC0KkUzpr+ CQ9ouZHlPgDKfgLm7uFq5z8ozEtkT6Edmbi85aY6hHIvOIcgv6rRUqxVufra5gqREMKtN2 lkPfQG9TyyoIzsezJFO2YlRtVLFrOVI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661538156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6G+fwE7qD46Hvx3slwj0sYknw2MfICjxdDcUgNjYMlY=; b=f+Q2yPv73wIGsM/kRQMbbaKZqP0yiS504lsgJ3TEzZ24E1aRhHhzDm2zoMBPShAqGC8eNZ 6uCBB/BbXaHj/yCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2C1BA13421; Fri, 26 Aug 2022 18:22:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mEK2CmwPCWMNGwAAMHmgww (envelope-from ); Fri, 26 Aug 2022 18:22:36 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Richard Biener Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 1/2] vec: Add array_slice constructors from non-const and gc vectors Date: Fri, 26 Aug 2022 20:22:35 +0200 Message-Id: References: Cc: GCC Patches , Richard Sandiford In-Reply-To: To: Martin Jambor X-Mailer: iPhone Mail (19G82) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: > Am 26.08.2022 um 18:39 schrieb Martin Jambor : >=20 > =EF=BB=BFHi, >=20 > This patch adds constructors of array_slice that are required to > create them from non-const (heap or auto) vectors or from GC vectors. >=20 > The use of non-const array_slices is somewhat limited, as creating one > from const vec still leads to array_slice, > so I eventually also only resorted to having read-only array_slices. > But I do need the constructor from the gc vector. >=20 > Bootstrapped and tested along code that actually uses it on > x86_64-linux. OK for trunk? >=20 > Thanks, >=20 > Martin >=20 >=20 > gcc/ChangeLog: >=20 > 2022-08-08 Martin Jambor >=20 > * vec.h (array_slice): Add constructors for non-const reference to > heap vector and pointers to heap vectors. > --- > gcc/vec.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) >=20 > diff --git a/gcc/vec.h b/gcc/vec.h > index eed075addc9..b0477e1044c 100644 > --- a/gcc/vec.h > +++ b/gcc/vec.h > @@ -2264,6 +2264,18 @@ public: > array_slice (const vec &v) > : m_base (v.address ()), m_size (v.length ()) {} >=20 > + template > + array_slice (vec &v) > + : m_base (v.address ()), m_size (v.length ()) {} > + > + template > + array_slice (const vec *v) > + : m_base (v ? v->address () : nullptr), m_size (v ? v->length () : 0)= {} > + > + template > + array_slice (vec *v) > + : m_base (v ? v->address () : nullptr), m_size (v ? v->length () : 0)= {} > + I don=E2=80=99t quite understand why the generic ctor doesn=E2=80=99t cover t= he GC case. It looks more like reference vs pointer? > iterator begin () { return m_base; } > iterator end () { return m_base + m_size; } >=20 > --=20 > 2.37.2 >=20