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 498CD3858D28 for ; Wed, 18 Jan 2023 18:53:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 498CD3858D28 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=1674068026; h=from:from: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=+WlSn1odvVetTuwxNiuOpQOotyOvSrsskOgwSUIrMc0=; b=LzJZ2hmOe/+hl4th2UDFeqzSY0Yhxf5Ikgkj9leo8bZlaosKRQQKPTsDS1zN1BZ7Rx1wDw OWqw0AqcFoNbJDSsi9lCgLGhpCQ/ALW5AcBvpE6pNHk4EktsOHXdqHpYwlF79gX9HHFWMX D655KFsk7gxI7ZGTNnUPMEzXw+p8zJI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-asmuoW5NPGeJNlVDu7LVqw-1; Wed, 18 Jan 2023 13:53:45 -0500 X-MC-Unique: asmuoW5NPGeJNlVDu7LVqw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AB23C1C189A9; Wed, 18 Jan 2023 18:53:44 +0000 (UTC) Received: from localhost (unknown [10.33.36.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70D21C15BAE; Wed, 18 Jan 2023 18:53:44 +0000 (UTC) Date: Wed, 18 Jan 2023 18:53:43 +0000 From: Jonathan Wakely To: Dimitrij Mijoski Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: [PATCH] libstdc++: testsuite: Simplify codecvt_unicode Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="8W4jes8SAazJoX+l" Content-Disposition: inline X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,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: --8W4jes8SAazJoX+l Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline On 17/01/23 22:12 +0100, Dimitrij Mijoski wrote: >Stop using unique_ptr, create some objects directly. > >libstdc++-v3/ChangeLog: > > * testsuite/22_locale/codecvt/codecvt_unicode.cc: Simplify. > * testsuite/22_locale/codecvt/codecvt_unicode.h: Simplify. > * testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc: Simplify. >--- > .../22_locale/codecvt/codecvt_unicode.cc | 18 ++++++++++-------- > .../22_locale/codecvt/codecvt_unicode.h | 9 +-------- > .../codecvt/codecvt_unicode_wchar_t.cc | 12 ++++++------ > 3 files changed, 17 insertions(+), 22 deletions(-) > >diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc >index ae4b6c896..3d7393e4a 100644 >--- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc >+++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc >@@ -29,11 +29,12 @@ test_utf8_utf32_codecvts () > using codecvt_c32 = codecvt; > auto loc_c = locale::classic (); > VERIFY (has_facet (loc_c)); >+ > auto &cvt = use_facet (loc_c); > test_utf8_utf32_codecvts (cvt); > >- auto cvt_ptr = to_unique_ptr (new codecvt_utf8 ()); >- test_utf8_utf32_codecvts (*cvt_ptr); >+ auto cvt2 = codecvt_utf8 (); This doesn't compile in C++11 or C++14, because there's no guaranteed elision. I've pushed the attached change instead. Thanks for the patch. --8W4jes8SAazJoX+l Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 7d0cdbbcdd1c9e5e709d0be7d1843e8c1045fd16 Author: Dimitrij Mijoski Date: Tue Jan 17 21:12:12 2023 libstdc++: testsuite: Simplify codecvt_unicode Stop using unique_ptr, create some objects directly. libstdc++-v3/ChangeLog: * testsuite/22_locale/codecvt/codecvt_unicode.cc: Simplify. * testsuite/22_locale/codecvt/codecvt_unicode.h: Simplify. * testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc: Simplify. diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc index ae4b6c8968f..df1a2b4cc51 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc @@ -29,11 +29,12 @@ test_utf8_utf32_codecvts () using codecvt_c32 = codecvt; auto loc_c = locale::classic (); VERIFY (has_facet (loc_c)); + auto &cvt = use_facet (loc_c); test_utf8_utf32_codecvts (cvt); - auto cvt_ptr = to_unique_ptr (new codecvt_utf8 ()); - test_utf8_utf32_codecvts (*cvt_ptr); + codecvt_utf8 cvt2; + test_utf8_utf32_codecvts (cvt2); } void @@ -42,21 +43,22 @@ test_utf8_utf16_codecvts () using codecvt_c16 = codecvt; auto loc_c = locale::classic (); VERIFY (has_facet (loc_c)); + auto &cvt = use_facet (loc_c); test_utf8_utf16_cvts (cvt); - auto cvt_ptr = to_unique_ptr (new codecvt_utf8_utf16 ()); - test_utf8_utf16_cvts (*cvt_ptr); + codecvt_utf8_utf16 cvt2; + test_utf8_utf16_cvts (cvt2); - auto cvt_ptr2 = to_unique_ptr (new codecvt_utf8_utf16 ()); - test_utf8_utf16_cvts (*cvt_ptr2); + codecvt_utf8_utf16 cvt3; + test_utf8_utf16_cvts (cvt3); } void test_utf8_ucs2_codecvts () { - auto cvt_ptr = to_unique_ptr (new codecvt_utf8 ()); - test_utf8_ucs2_cvts (*cvt_ptr); + codecvt_utf8 cvt; + test_utf8_ucs2_cvts (cvt); } int diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h index 99d1a46840e..fbdc7a35b28 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h @@ -15,18 +15,11 @@ // with this library; see the file COPYING3. If not see // . +#include #include #include -#include #include -template -std::unique_ptr -to_unique_ptr (T *ptr) -{ - return std::unique_ptr (ptr); -} - struct test_offsets_ok { size_t in_size, out_size; diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc index 169504939a2..4fd1bfec63a 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc @@ -27,8 +27,8 @@ void test_utf8_utf32_codecvts () { #if __SIZEOF_WCHAR_T__ == 4 - auto cvt_ptr = to_unique_ptr (new codecvt_utf8 ()); - test_utf8_utf32_codecvts (*cvt_ptr); + codecvt_utf8 cvt; + test_utf8_utf32_codecvts (cvt); #endif } @@ -36,8 +36,8 @@ void test_utf8_utf16_codecvts () { #if __SIZEOF_WCHAR_T__ >= 2 - auto cvt_ptr = to_unique_ptr (new codecvt_utf8_utf16 ()); - test_utf8_utf16_cvts (*cvt_ptr); + codecvt_utf8_utf16 cvt; + test_utf8_utf16_cvts (cvt); #endif } @@ -45,8 +45,8 @@ void test_utf8_ucs2_codecvts () { #if __SIZEOF_WCHAR_T__ == 2 - auto cvt_ptr = to_unique_ptr (new codecvt_utf8 ()); - test_utf8_ucs2_cvts (*cvt_ptr); + codecvt_utf8 cvt; + test_utf8_ucs2_cvts (cvt); #endif } --8W4jes8SAazJoX+l--