On 06/05/20 11:01 +0100, Jonathan Wakely wrote: >On 04/02/20 14:55 +0100, Martin Liska wrote: >>diff --git a/libstdc++-v3/include/parallel/multiway_merge.h b/libstdc++-v3/include/parallel/multiway_merge.h >>index 983c7b2bd9a..97a9ce0feb7 100644 >>--- a/libstdc++-v3/include/parallel/multiway_merge.h >>+++ b/libstdc++-v3/include/parallel/multiway_merge.h >>@@ -118,7 +118,7 @@ namespace __gnu_parallel >> * @return @c true if less. */ >> friend bool >> operator<(_GuardedIterator<_RAIter, _Compare>& __bi1, >>- _GuardedIterator<_RAIter, _Compare>& __bi2) >>+ _GuardedIterator<_RAIter, const _Compare>& __bi2) >> { >> if (__bi1._M_current == __bi1._M_end) // __bi1 is sup >> return __bi2._M_current == __bi2._M_end; // __bi2 is not sup >>@@ -188,7 +188,7 @@ namespace __gnu_parallel >> * @return @c true if less. */ >> friend bool >> operator<(_UnguardedIterator<_RAIter, _Compare>& __bi1, >>- _UnguardedIterator<_RAIter, _Compare>& __bi2) >>+ _UnguardedIterator<_RAIter, const _Compare>& __bi2) >> { >> // Normal compare. >> return (__bi1.__comp)(*__bi1, *__bi2); > > >This is completely bogus, please revert. > >The cppcheck warning is saying that it could be: > > const _UnguardedIterator<_RAIter, _Compare>& > >which is completely different from: > > _UnguardedIterator<_RAIter, const _Compare>& > >Also both parameters of operator< should have been changed, not just >one, and operator<= should have the same change. > >But cppcheck is completely wrong anyway. The operator* member of >_GuardedIterator and _UnguardedIterator is not const, so trying to >dereference *__b1 and *__b2 would fail. > >Nack nack nack. Here's a correct fix for the cppcheck complaint. Tested powerpc64le-linux, 'make check check-parallel', committed to master.