From patchwork Fri Nov 26 23:09: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: 48205 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5839C3857C7A for ; Fri, 26 Nov 2021 23:12:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5839C3857C7A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637968322; bh=DSEIg0LawwzHdoINLSzjH3tVGnGAMe/tYjBGdJTOols=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Chbd+SfTHKVpfLpgShvX+0BK7mgSf2WKgk6KfVydpN1sLxlsPf7jCrbPIzZgpuTdL mRU/5kPbKGEYRbPprWLfnRjSVKQ44tOmUK+hvOx5vMA8Su3t+ZIuL6Bo4QuimVWlnG huRTePxO+pxCzq58lJOlAo6LZOjVGLnjtwyDKSKY= 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 033C63857811 for ; Fri, 26 Nov 2021 23:09:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 033C63857811 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-492-xc6Qv_1MNs2_yrFhyuWC5g-1; Fri, 26 Nov 2021 18:09:02 -0500 X-MC-Unique: xc6Qv_1MNs2_yrFhyuWC5g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C0DAD1853024; Fri, 26 Nov 2021 23:09:01 +0000 (UTC) Received: from localhost (unknown [10.33.36.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C3565D9CA; Fri, 26 Nov 2021 23:09:01 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix test that fails in C++20 mode Date: Fri, 26 Nov 2021 23:09:00 +0000 Message-Id: <20211126230900.1843678-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.0 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.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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86_64-linux, pushed to trunk. This test was written to verify that the LWG 3265 changes work. But those changes were superseded by LWG 3435, and the test is now incorrect according to the current draft. The assignment operator is now constrained to also require convertibility, which makes the test fail. Change the Iter type to be convertible from int*, but make it throw an exception if that conversion is used. Change the test from compile-only to run, so we verify that the exception isn't thrown. libstdc++-v3/ChangeLog: * testsuite/24_iterators/move_iterator/dr3265.cc: Fix test to account for LWG 3435 resolution. --- .../24_iterators/move_iterator/dr3265.cc | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/libstdc++-v3/testsuite/24_iterators/move_iterator/dr3265.cc b/libstdc++-v3/testsuite/24_iterators/move_iterator/dr3265.cc index e4219b8c78b..3ce0df5d111 100644 --- a/libstdc++-v3/testsuite/24_iterators/move_iterator/dr3265.cc +++ b/libstdc++-v3/testsuite/24_iterators/move_iterator/dr3265.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-do compile { target c++11 } } +// { dg-do run { target c++11 } } #include @@ -27,18 +27,18 @@ struct Iter using reference = int&; using difference_type = std::ptrdiff_t; - Iter(); + Iter() { } - // Construction from int* is not valid: - Iter(int*) = delete; + // Construction from int* should not be used: + Iter(int*) { throw 1; } - // Assignment from int* is valid: - Iter& operator=(int*); + // Assignment from int* is OK: + Iter& operator=(int*) { return *this; } - Iter& operator++(); - Iter operator++(int); - int& operator*() const; - int* operator->() const; + Iter& operator++() { return *this; } + Iter operator++(int) { return *this; } + int& operator*() const { static int i; return i; } + int* operator->() const { return &**this; } template friend bool operator==(Iter, Iter); }; @@ -49,3 +49,8 @@ void test01() int i = 0; m = std::make_move_iterator(&i); // Should use assignment not construction } + +int main() +{ + test01(); +}