]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix PSTL test that fails in C++20
authorJonathan Wakely <jwakely@redhat.com>
Thu, 1 Jun 2023 15:49:53 +0000 (16:49 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 1 Jun 2023 15:54:24 +0000 (16:54 +0100)
This test fails in C++20 and later due to a warning:

warning: C++20 says that these are ambiguous, even though the second is reversed:
note: candidate 1: 'bool MyClass::operator==(const MyClass&)'
note: candidate 2: 'bool MyClass::operator==(const MyClass&)' (reversed)
note: try making the operator a 'const' member function
FAIL: 26_numerics/pstl/numeric_ops/transform_reduce.cc (test for excess errors)

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc:
Add const to equality operator.

libstdc++-v3/testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc

index ec020b42bbb4246336173a6055167220e997169c..bec1c14127884bbe18461e972f7d2a825deae290 100644 (file)
@@ -68,7 +68,7 @@ class MyClass
     }
     friend MyClass operator*(const MyClass& x, const MyClass& y) { return MyClass(x.my_field * y.my_field); }
     bool
-    operator==(const MyClass& in)
+    operator==(const MyClass& in) const
     {
         return my_field == in.my_field;
     }