public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r11-9923] libstdc++: Fix test that fails in C++20 mode
Date: Thu, 21 Apr 2022 15:33:40 +0000 (GMT)	[thread overview]
Message-ID: <20220421153340.3B64B38485BC@sourceware.org> (raw)

https://gcc.gnu.org/g:47b67521d457cbf07dd60be3d0fdc8c41a14c962

commit r11-9923-g47b67521d457cbf07dd60be3d0fdc8c41a14c962
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Nov 26 22:53:02 2021 +0000

    libstdc++: Fix test that fails in C++20 mode
    
    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.
    
    (cherry picked from commit 52b769437a4d1ca50f4ef5bdad65b12115ded845)

Diff:
---
 .../testsuite/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
 // <http://www.gnu.org/licenses/>.
 
-// { dg-do compile { target c++11 } }
+// { dg-do run { target c++11 } }
 
 #include <iterator>
 
@@ -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<int N> 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();
+}


                 reply	other threads:[~2022-04-21 15:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220421153340.3B64B38485BC@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).