https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92472
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to David Binderman from comment #0)
> Message:
>
> trunk/libstdc++-v3/include/parallel/multiway_merge.h:121:40: style:
> Parameter '__bi2' can be declared with const [constParameter]
> trunk/libstdc++-v3/include/parallel/multiway_merge.h:191:42: style:
> Parameter '__bi2' can be declared with const [constParameter]
>
> Patch:
>
> Index: libstdc++-v3/include/parallel/multiway_merge.h
> ===================================================================
> --- libstdc++-v3/include/parallel/multiway_merge.h (revision 278050)
> +++ libstdc++-v3/include/parallel/multiway_merge.h (working copy)
> @@ -118,7 +118,7 @@
> * @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 @@
> * @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 400% wrong. It doesn't even address what cppcheck is complaining about,
and cppcheck is drunk anyway. Those parameter can NOT be const, because *__b1
and *__b2 will not compile if they're const, because operator* is not const.
> All patches seemed to bootstrap ok.
But what about testing them?