From patchwork Tue Oct 19 10:51:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1543201 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=hb2ipuoU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HYVtm209Jz9sPB for ; Tue, 19 Oct 2021 21:52:14 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F65A3858426 for ; Tue, 19 Oct 2021 10:52:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F65A3858426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634640732; bh=HxqQ4T/RNN9gF06/VoUMMgjbSKWfrm8HENO8DzH7u94=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hb2ipuoU2uZ1DTGhgbxC2AU6mbJKwirj2ErrKXgG/mlqxtWkzxyFlGk5Svpo4TnvF elr0HghBpniD1pRsiWfqphdPKnRW/PoFjrvETI/X0csHv9cSYpCrRL3tuBi6vpoZvu 4RvtesXuSH2MDQxom1SRLLqItQ1TYTnRJXJL4lww= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 549923858428 for ; Tue, 19 Oct 2021 10:51:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 549923858428 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-100-lY2u3U1jOm6VZFlotGl5AA-1; Tue, 19 Oct 2021 06:51:02 -0400 X-MC-Unique: lY2u3U1jOm6VZFlotGl5AA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5AD91006AA7; Tue, 19 Oct 2021 10:51:01 +0000 (UTC) Received: from localhost (unknown [10.33.36.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63E017093A; Tue, 19 Oct 2021 10:51:01 +0000 (UTC) Date: Tue, 19 Oct 2021 11:51:00 +0100 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix mem-initializer in std::move_only_function [PR102825] Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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, TVD_SPACE_RATIO, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" libstdc++-v3/ChangeLog: PR libstdc++/102825 * include/bits/mofunc_impl.h (move_only_function): Remove invalid base initializer. * testsuite/20_util/move_only_function/cons.cc: Instantiate constructors to check bodies. Tested powerpc64le-linux. Committed to trunk. commit 9890b12c72c02828c691f22198c3e0afd8678991 Author: Jonathan Wakely Date: Tue Oct 19 09:16:56 2021 libstdc++: Fix mem-initializer in std::move_only_function [PR102825] libstdc++-v3/ChangeLog: PR libstdc++/102825 * include/bits/mofunc_impl.h (move_only_function): Remove invalid base initializer. * testsuite/20_util/move_only_function/cons.cc: Instantiate constructors to check bodies. diff --git a/libstdc++-v3/include/bits/mofunc_impl.h b/libstdc++-v3/include/bits/mofunc_impl.h index 543c6f547b7..968d235f867 100644 --- a/libstdc++-v3/include/bits/mofunc_impl.h +++ b/libstdc++-v3/include/bits/mofunc_impl.h @@ -108,7 +108,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION move_only_function(in_place_type_t<_Tp>, initializer_list<_Up> __il, _Args&&... __args) noexcept(_S_nothrow_init<_Tp, initializer_list<_Up>&, _Args...>()) - : _Mofunc_base(nullptr), _M_invoke(&_S_invoke<_Tp>) + : _M_invoke(&_S_invoke<_Tp>) { static_assert(is_same_v, _Tp>); _M_init<_Tp>(__il, std::forward<_Args>(__args)...); diff --git a/libstdc++-v3/testsuite/20_util/move_only_function/cons.cc b/libstdc++-v3/testsuite/20_util/move_only_function/cons.cc index 0992f107003..d8a0a4ab2b0 100644 --- a/libstdc++-v3/testsuite/20_util/move_only_function/cons.cc +++ b/libstdc++-v3/testsuite/20_util/move_only_function/cons.cc @@ -96,3 +96,30 @@ static_assert( ! is_nothrow_constructible_v, in_place_type_t, int> ); static_assert( is_nothrow_constructible_v, in_place_type_t, int, int> ); + +struct I { + I(int, const char*); + I(std::initializer_list); + int operator()() const noexcept; +}; + +static_assert( is_constructible_v, + std::in_place_type_t, + int, const char*> ); +static_assert( is_constructible_v, + std::in_place_type_t, + std::initializer_list> ); + +void +test_instantiation() +{ + // Instantiate the constructor bodies + move_only_function f0; + move_only_function f1(nullptr); + move_only_function f2( I(1, "two") ); + move_only_function f3(std::in_place_type, 3, "four"); + move_only_function f4(std::in_place_type, // PR libstdc++/102825 + { 'P', 'R', '1', '0', '2', '8', '2', '5'}); + auto f5 = std::move(f4); + f4 = std::move(f5); +}