From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id A2857383F85E for ; Wed, 6 May 2020 10:01:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A2857383F85E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-abxfdxHXO12I1fkvpxMpkA-1; Wed, 06 May 2020 06:01:29 -0400 X-MC-Unique: abxfdxHXO12I1fkvpxMpkA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7FDBA1009454; Wed, 6 May 2020 10:01:28 +0000 (UTC) Received: from localhost (unknown [10.33.36.248]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0ABA9605DF; Wed, 6 May 2020 10:01:27 +0000 (UTC) Date: Wed, 6 May 2020 11:01:27 +0100 From: Jonathan Wakely To: Martin Liska Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: [PATCH 4/4] Use const for template argument. Message-ID: <20200506100127.GY2678@redhat.com> References: MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Spam-Status: No, score=-20.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 May 2020 10:01:35 -0000 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 =3D=3D __bi1._M_end) // __bi1 is sup > return __bi2._M_current =3D=3D __bi2._M_end; // __bi2 is not su= p >@@ -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<=3D 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.