From patchwork Mon Jun 1 17:31:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1301840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: 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=xtnL57+V; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 49bMfX2g3kz9sVX for ; Tue, 2 Jun 2020 03:31:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 442373870846; Mon, 1 Jun 2020 17:31:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 442373870846 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591032687; bh=wf1KrmtBwekpW6m/v5l0Sl2X5jDS3+G9WCNLXybV6vM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xtnL57+VTEkcavhlqiT2kuvQZDF/BeWa4WBxbtB5NxmV3R8XerMenrW+xQR8Yyvuv ioATscXEkTpeUWH64Vd5bfx4wHmYLypYq6Gt6OfPW+rz2LjaY91Q5z9lLATi3HXFC8 6dxxszOTCY3jwBykOZA8m+q5GW/QBdmQWK4+2bTc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id BB1CF386F47D for ; Mon, 1 Jun 2020 17:31:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BB1CF386F47D 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-302-IlL-UmT6NUaM-g7EL8birw-1; Mon, 01 Jun 2020 13:31:20 -0400 X-MC-Unique: IlL-UmT6NUaM-g7EL8birw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 65214131533; Mon, 1 Jun 2020 17:31:13 +0000 (UTC) Received: from localhost (unknown [10.33.36.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id F374278EF0; Mon, 1 Jun 2020 17:31:12 +0000 (UTC) Date: Mon, 1 Jun 2020 18:31:11 +0100 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix __gnu_test::input_iterator_wrapper::operator++(int) Message-ID: <20200601173111.GA3768561@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-17.3 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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@gcc.gnu.org Sender: "Gcc-patches" I noticed recently that our input_iterator_wrapper utility for writing tests has the following post-increment operator: void operator++(int) { ++*this; } That fails to meet the Cpp17InputIterator requirement that *r++ is valid. This change makes it return a non-void proxy type that can be deferenced to produce another proxy, which is convertible to the value_type. The second proxy converts to const T& to ensure it can't be written to. * testsuite/util/testsuite_iterators.h: (input_iterator_wrapper::operator++(int)): Return proxy object. Tested powerpc64le-linux, committed to master. commit 118158b646d402b0fb5d760e4827611b731fe6f3 Author: Jonathan Wakely Date: Mon Jun 1 18:30:47 2020 +0100 libstdc++: Fix __gnu_test::input_iterator_wrapper::operator++(int) I noticed recently that our input_iterator_wrapper utility for writing tests has the following post-increment operator: void operator++(int) { ++*this; } That fails to meet the Cpp17InputIterator requirement that *r++ is valid. This change makes it return a non-void proxy type that can be deferenced to produce another proxy, which is convertible to the value_type. The second proxy converts to const T& to ensure it can't be written to. * testsuite/util/testsuite_iterators.h: (input_iterator_wrapper::operator++(int)): Return proxy object. diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index 5be47f47915..71b672c85fa 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -208,6 +208,17 @@ namespace __gnu_test : public std::iterator::type, std::ptrdiff_t, T*, T&> { + struct post_inc_proxy + { + struct deref_proxy + { + T* ptr; + operator const T&() const { return *ptr; } + } p; + + deref_proxy operator*() const { return p; } + }; + protected: input_iterator_wrapper() : ptr(0), SharedInfo(0) { } @@ -266,10 +277,12 @@ namespace __gnu_test return *this; } - void + post_inc_proxy operator++(int) { + post_inc_proxy tmp = { { ptr } }; ++*this; + return tmp; } #if __cplusplus >= 201103L