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 ESMTP id 208CB385802E for ; Mon, 11 Oct 2021 19:37:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 208CB385802E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-412-GJkmpERNMcO80mlTseqxvg-1; Mon, 11 Oct 2021 15:37:44 -0400 X-MC-Unique: GJkmpERNMcO80mlTseqxvg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 56ED218D6A30; Mon, 11 Oct 2021 19:37:43 +0000 (UTC) Received: from localhost (unknown [10.33.37.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC56760C5F; Mon, 11 Oct 2021 19:37:42 +0000 (UTC) Date: Mon, 11 Oct 2021 20:37:42 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Simplify std::basic_regex::assign Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="cl+iArZAFhXpXM5W" Content-Disposition: inline X-Spam-Status: No, score=-13.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_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2021 19:37:47 -0000 --cl+iArZAFhXpXM5W Content-Type: text/plain; charset=us-ascii Content-Disposition: inline We know that if __is_contiguous_iterator is true then we have a pointer or a __normal_iterator that wraps a pointer, so we don't need to use std::__to_address. libstdc++-v3/ChangeLog: * include/bits/regex.h (basic_regex::assign(Iter, Iter)): Avoid std::__to_address by using poitner directly or using base() member of __normal_iterator. Tested powerpc64le-linux. Committed to trunk. --cl+iArZAFhXpXM5W Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 247bac507e63b32d4dc23ef1c55f300aafea24c6 Author: Jonathan Wakely Date: Mon Oct 11 17:19:43 2021 libstdc++: Simplify std::basic_regex::assign We know that if __is_contiguous_iterator is true then we have a pointer or a __normal_iterator that wraps a pointer, so we don't need to use std::__to_address. libstdc++-v3/ChangeLog: * include/bits/regex.h (basic_regex::assign(Iter, Iter)): Avoid std::__to_address by using poitner directly or using base() member of __normal_iterator. diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index 3c44bcd7e33..a3990183580 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -682,15 +682,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 assign(_InputIterator __first, _InputIterator __last, flag_type __flags = ECMAScript) { -#if __cplusplus >= 201703L +#if __cpp_if_constexpr >= 201606L using _ValT = typename iterator_traits<_InputIterator>::value_type; if constexpr (__detail::__is_contiguous_iter<_InputIterator>::value && is_same_v<_ValT, value_type>) { __glibcxx_requires_valid_range(__first, __last); - const auto __len = __last - __first; - const _Ch_type* __p = std::__to_address(__first); - _M_compile(__p, __p + __len, __flags); + if constexpr (is_pointer_v<_InputIterator>) + _M_compile(__first, __last, __flags); + else // __normal_iterator<_T*, C> + _M_compile(__first.base(), __last.base(), __flags); } else #endif --cl+iArZAFhXpXM5W--