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.133.124]) by sourceware.org (Postfix) with ESMTPS id A7BED389000C for ; Thu, 20 Jun 2024 15:32:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A7BED389000C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A7BED389000C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718897568; cv=none; b=fp0Jqx3bpWcMILoOpoNWRWC57Bs1RNNHjwUUkeEV43XKTkcK/9Nrl9+39OpN7yndcJ0ngniCcZ1zAq8yYkJZTyMwLIG/Yhy+iZd8xGTEKyitVVu4Eju7/0kUf2b6VhDa6TNdQ+pReI0MYYk0LKgecY2BnWqAH/maQbjoQ3IN97M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718897568; c=relaxed/simple; bh=K9znRjYV5y5Cg7GmMWr2BYo5HBaW8XmwZr/hvGmBEFs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JUDUjRLAgoMfBge/j/AEy1KHsJBl4fYaRPbyCd5RDlg9rJ5eE2MrDOW4CPXa7EVix2HCznv3w37OvAGDVrNRjEVgpOslsHxCzfKyQa6mvLzYc76IavIWiJZDdhtzMOLYU6qWStw5I/lJByVwXeSI8/bI7gOgJfdOHbG07F6dSTo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718897566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sm13/j4gsSDbl/jruBlNJVzF7/e9HmGWabpKG/EnGK8=; b=W/hu2FQcnN1MQLGHums5ZZoydGMwb9X0QQ2mYwcQca+A3MvKE7QtbLRAQRzvlsJsqW4M/t tQ8+LgtIj5UxGtiFe7qLAcfIJlqVsGQRVt3AJvvblOx8AwcRoQXYsLHbXu+w+ktadMCMlT M1Osmob1h5hzYiSKEqe1RyTDLqvZc7o= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-whFIHzPnNPmy6zYX1B8Hjw-1; Thu, 20 Jun 2024 11:32:43 -0400 X-MC-Unique: whFIHzPnNPmy6zYX1B8Hjw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E4D5A1956086; Thu, 20 Jun 2024 15:32:41 +0000 (UTC) Received: from localhost (unknown [10.42.28.182]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 72DAD1956087; Thu, 20 Jun 2024 15:32:41 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 1/4] libstdc++: Don't use std::__is_scalar in std::valarray initialization [PR115497] Date: Thu, 20 Jun 2024 16:30:13 +0100 Message-ID: <20240620153240.2022128-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.8 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,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_NONE,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: We know that valarray's value_type must be DefaultConstructible, so we don't need to test that. I think __is_trivial is sufficient to tell us we can use memset to value-initialize the elements. Tested x86_64-linux. -- >8 -- This removes the use of the std::__is_scalar trait from , where it can be replaced by __is_trivial. It's used to decide whether we can use memset to value-initialize valarray elements, but memset is suitable for any trivial types, because value-initializing them is equivalent to filling them with zeros. This is another step towards removing the class templates in that conflict with Clang built-in names. libstdc++-v3/ChangeLog: PR libstdc++/115497 * include/bits/valarray_array.h (__valarray_default_construct): Use __is_trivial(_Tp). instead of __is_scalar<_Tp>. --- libstdc++-v3/include/bits/valarray_array.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/valarray_array.h b/libstdc++-v3/include/bits/valarray_array.h index 66b74f9aaac..07c49ce1057 100644 --- a/libstdc++-v3/include/bits/valarray_array.h +++ b/libstdc++-v3/include/bits/valarray_array.h @@ -80,7 +80,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct _Array_default_ctor<_Tp, true> { - // For fundamental types, it suffices to say 'memset()' + // For trivial types, it suffices to say 'memset()' inline static void _S_do_it(_Tp* __b, _Tp* __e) { __builtin_memset(__b, 0, (__e - __b) * sizeof(_Tp)); } @@ -90,7 +90,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline void __valarray_default_construct(_Tp* __b, _Tp* __e) { - _Array_default_ctor<_Tp, __is_scalar<_Tp>::__value>::_S_do_it(__b, __e); + _Array_default_ctor<_Tp, __is_trivial(_Tp)>::_S_do_it(__b, __e); } // Turn a raw-memory into an array of _Tp filled with __t -- 2.45.2