Skip to content
Snippets Groups Projects
Commit 52b76943 authored by Jonathan Wakely's avatar Jonathan Wakely
Browse files

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.
parent 33adfd0d
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile { target c++11 } } // { dg-do run { target c++11 } }
#include <iterator> #include <iterator>
...@@ -27,18 +27,18 @@ struct Iter ...@@ -27,18 +27,18 @@ struct Iter
using reference = int&; using reference = int&;
using difference_type = std::ptrdiff_t; using difference_type = std::ptrdiff_t;
Iter(); Iter() { }
// Construction from int* is not valid: // Construction from int* should not be used:
Iter(int*) = delete; Iter(int*) { throw 1; }
// Assignment from int* is valid: // Assignment from int* is OK:
Iter& operator=(int*); Iter& operator=(int*) { return *this; }
Iter& operator++(); Iter& operator++() { return *this; }
Iter operator++(int); Iter operator++(int) { return *this; }
int& operator*() const; int& operator*() const { static int i; return i; }
int* operator->() const; int* operator->() const { return &**this; }
template<int N> friend bool operator==(Iter, Iter); template<int N> friend bool operator==(Iter, Iter);
}; };
...@@ -49,3 +49,8 @@ void test01() ...@@ -49,3 +49,8 @@ void test01()
int i = 0; int i = 0;
m = std::make_move_iterator(&i); // Should use assignment not construction m = std::make_move_iterator(&i); // Should use assignment not construction
} }
int main()
{
test01();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment