]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix tests with non-const operator==
authorJonathan Wakely <jwakely@redhat.com>
Thu, 10 Nov 2022 14:11:27 +0000 (14:11 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 11 Nov 2022 04:00:58 +0000 (04:00 +0000)
These tests fail in strict -std=c++20 mode but their equality ops don't
need to be non-const, it looks like an accident.

This fixes two FAILs with -std=c++20:
FAIL: 20_util/tuple/swap.cc (test for excess errors)
FAIL: 26_numerics/valarray/87641.cc (test for excess errors)

libstdc++-v3/ChangeLog:

* testsuite/20_util/tuple/swap.cc (MoveOnly::operator==): Add
const qualifier.
* testsuite/26_numerics/valarray/87641.cc (X::operator==):
Likewise.

libstdc++-v3/testsuite/20_util/tuple/swap.cc
libstdc++-v3/testsuite/26_numerics/valarray/87641.cc

index c086a4f1a8e47d04a95da88d74ae9f8bae0f246a..30c8322f01c735740e67720b90e429d6e2b19e62 100644 (file)
@@ -38,7 +38,7 @@ struct MoveOnly
   MoveOnly(MoveOnly const&) = delete;
   MoveOnly& operator=(MoveOnly const&) = delete;
 
-  bool operator==(MoveOnly const& m)
+  bool operator==(MoveOnly const& m) const
   { return i == m.i; }
 
   void swap(MoveOnly& m)
index 38c35851716b9b7a03421fda022dfaaf72dfd8be..4a6e402831ddd79c9e9928e5f87321fbad71cbc3 100644 (file)
@@ -39,7 +39,7 @@ struct X
   X() : val(1) { }
 
   X& operator+=(const X& x) { val += x.val; return *this; }
-  bool operator==(const X& x) { return val == x.val; }
+  bool operator==(const X& x) const { return val == x.val; }
 
   int val;
 };