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 40261384699F for ; Mon, 12 Dec 2022 14:01:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 40261384699F 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=1670853706; 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=X8WdKc0M2TftfLvdQq4DAastFfvJm2E8RKYbleW6U2M=; b=bszVccGra9ASsu1vOKZnfl46uLLt+yheG63VvU4r5I2GQDl3ucHakTNw9pOOhYS1z5jnjP LmD2pGGadabQNwVWa5Cz2gxWWDIMDIsDnR4d7n0qtJIVVrEqD6ia+/bVJXcjtPLSDe7Arm R1a8vMChq8UZLZ8yWaLUyeY1WWQMtG0= 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-213-tRmj5LnGPD2DERzOV0MNiA-1; Mon, 12 Dec 2022 09:01:45 -0500 X-MC-Unique: tRmj5LnGPD2DERzOV0MNiA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C7DCA3C0F673; Mon, 12 Dec 2022 14:01:42 +0000 (UTC) Received: from localhost (unknown [10.33.36.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E3A240C2005; Mon, 12 Dec 2022 14:01:42 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix constraint on std::basic_format_string [PR108024] Date: Mon, 12 Dec 2022 14:01:39 +0000 Message-Id: <20221212140139.716962-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 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_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: Tested x86_64-linux. Pushed to trunk. -- >8-- Also remove some redundant std::move calls for return statements. libstdc++-v3/ChangeLog: PR libstdc++/108024 * include/std/format (basic_format_string): Fix constraint. * testsuite/std/format/format_string.cc: New test. --- libstdc++-v3/include/std/format | 10 ++++++---- .../testsuite/std/format/format_string.cc | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 libstdc++-v3/testsuite/std/format/format_string.cc diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 269f8f6cc6a..9c928371415 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -110,7 +110,8 @@ namespace __format template struct basic_format_string { - template> _Tp> + template + requires convertible_to> consteval basic_format_string(const _Tp& __s); @@ -609,7 +610,7 @@ namespace __format else for (_CharT __c : __str) *__out++ = __c; - return std::move(__out); + return __out; } // Write STR to OUT with NFILL copies of FILL_CHAR specified by ALIGN. @@ -664,7 +665,7 @@ namespace __format __out = __format::__write(std::move(__out), __str); __pad(__r, __out); - return std::move(__out); + return __out; } // A lightweight optional. @@ -3626,7 +3627,8 @@ namespace __format /// @endcond template - template> _Tp> + template + requires convertible_to> consteval basic_format_string<_CharT, _Args...>:: basic_format_string(const _Tp& __s) diff --git a/libstdc++-v3/testsuite/std/format/format_string.cc b/libstdc++-v3/testsuite/std/format/format_string.cc new file mode 100644 index 00000000000..1dd6ca8f125 --- /dev/null +++ b/libstdc++-v3/testsuite/std/format/format_string.cc @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++20" } +// { dg-do compile { target c++20 } } + +#include + +struct Str +{ + consteval operator std::string_view() const { return ""; } + operator std::string_view() = delete; +}; + +// PR libstdc++/108024 +static_assert( std::is_constructible_v, const Str&> ); +static_assert( std::is_convertible_v> ); + +constinit std::format_string<> s = Str(); -- 2.38.1