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 A4EBA3858C83 for ; Fri, 8 Apr 2022 17:38:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A4EBA3858C83 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-147-rPQpMZ98NnGCLzU8Oga-4g-1; Fri, 08 Apr 2022 13:38:07 -0400 X-MC-Unique: rPQpMZ98NnGCLzU8Oga-4g-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 0CD0C282B7E0; Fri, 8 Apr 2022 17:38:07 +0000 (UTC) Received: from localhost (unknown [10.33.36.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBB30407DEC4; Fri, 8 Apr 2022 17:38:06 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 1/3] libstdc++: Fix std::bad_expected_access constructor [PR105146] Date: Fri, 8 Apr 2022 18:38:04 +0100 Message-Id: <20220408173806.336422-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.7 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Fri, 08 Apr 2022 17:38:11 -0000 Tested x86_64-linux, pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: PR libstdc++/105146 * include/std/expected (bad_expected_access): Move constructor parameter. * testsuite/20_util/expected/bad.cc: New test. --- libstdc++-v3/include/std/expected | 2 +- libstdc++-v3/testsuite/20_util/expected/bad.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/20_util/expected/bad.cc diff --git a/libstdc++-v3/include/std/expected b/libstdc++-v3/include/std/expected index 39d07cda4a9..7b01a17fb57 100644 --- a/libstdc++-v3/include/std/expected +++ b/libstdc++-v3/include/std/expected @@ -95,7 +95,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION class bad_expected_access : public bad_expected_access { public: explicit - bad_expected_access(_Er __e) : _M_val(__e) { } + bad_expected_access(_Er __e) : _M_val(std::move(__e)) { } // XXX const char* what() const noexcept override; diff --git a/libstdc++-v3/testsuite/20_util/expected/bad.cc b/libstdc++-v3/testsuite/20_util/expected/bad.cc new file mode 100644 index 00000000000..17bc6d69e88 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/expected/bad.cc @@ -0,0 +1,15 @@ +// { dg-options "-std=gnu++23" } +// { dg-do compile } + +#include + +struct E { + E() = default; + E(E&&) = default; +}; + +void +test_pr105146() +{ + std::bad_expected_access(E{}); +} -- 2.34.1