This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix PR 17741


Paolo Carlini wrote:

Chris Jefferson wrote:

PR 17741 is a simple problem, where the specialisations of find and find_if have not been uglified. This simple patch fixes it.

Tested on x86/linux.


Hi Chris.

I have two comments of the type once-and-for-all ;) ...

1- Please follow our conventions for the ChangeLog entry (just have a look to the file)
2- Please use diff -u (-p unfortunately is not very useful for C++) and typically -R (again, just have a look to the past postings for the details)


Sorry sorry! I've tried again. Hopefully this patch is correct in all ways (famous last words...)

... and two more, specific to this patch:
   3- Do you actually have a testcase or not? ;)

Yep, now attached


4- In my opinion, this kind of change is more suited for v7-branch.

I agree. In fact I was torn about if I should bother submitting this, as I can't see anyone ever actually coming across this bug...

Chris
2004-10-28  Chris Jefferson  <chris@bubblescope.net>

	* include/bit/stl_algo.h (find(,,,input_iterator_tag)): Fix PR 17441
	uglify function name
	(find(,,,random_access_interator_tag)): ditto
	(find_if(,,,input_iterator_tag)): ditto
	(find_if(,,,random_access_iterator_tag)): ditto
	(find): use new uglified specialisation names
	(find_if): ditto

	* testsuite/25_algorithms/find.cc: New. Test for PR 17741.
Index: gcc/libstdc++-v3/include/bits/stl_algo.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libstdc++-v3/include/bits/stl_algo.h,v
retrieving revision 1.49
diff -p -c -3 -r1.49 stl_algo.h
*** gcc/libstdc++-v3/include/bits/stl_algo.h	6 Oct 2004 09:06:58 -0000	1.49
--- gcc/libstdc++-v3/include/bits/stl_algo.h	28 Oct 2004 16:33:48 -0000
*************** namespace std
*** 166,172 ****
    */
    template<typename _InputIterator, typename _Tp>
      inline _InputIterator
!     find(_InputIterator __first, _InputIterator __last,
  	 const _Tp& __val, input_iterator_tag)
      {
        while (__first != __last && !(*__first == __val))
--- 166,172 ----
    */
    template<typename _InputIterator, typename _Tp>
      inline _InputIterator
!     __find(_InputIterator __first, _InputIterator __last,
  	 const _Tp& __val, input_iterator_tag)
      {
        while (__first != __last && !(*__first == __val))
*************** namespace std
*** 181,187 ****
    */
    template<typename _InputIterator, typename _Predicate>
      inline _InputIterator
!     find_if(_InputIterator __first, _InputIterator __last,
  	    _Predicate __pred, input_iterator_tag)
      {
        while (__first != __last && !__pred(*__first))
--- 181,187 ----
    */
    template<typename _InputIterator, typename _Predicate>
      inline _InputIterator
!     __find_if(_InputIterator __first, _InputIterator __last,
  	    _Predicate __pred, input_iterator_tag)
      {
        while (__first != __last && !__pred(*__first))
*************** namespace std
*** 196,202 ****
    */
    template<typename _RandomAccessIterator, typename _Tp>
      _RandomAccessIterator
!     find(_RandomAccessIterator __first, _RandomAccessIterator __last,
  	 const _Tp& __val, random_access_iterator_tag)
      {
        typename iterator_traits<_RandomAccessIterator>::difference_type
--- 196,202 ----
    */
    template<typename _RandomAccessIterator, typename _Tp>
      _RandomAccessIterator
!     __find(_RandomAccessIterator __first, _RandomAccessIterator __last,
  	 const _Tp& __val, random_access_iterator_tag)
      {
        typename iterator_traits<_RandomAccessIterator>::difference_type
*************** namespace std
*** 248,254 ****
    */
    template<typename _RandomAccessIterator, typename _Predicate>
      _RandomAccessIterator
!     find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,
  	    _Predicate __pred, random_access_iterator_tag)
      {
        typename iterator_traits<_RandomAccessIterator>::difference_type
--- 248,254 ----
    */
    template<typename _RandomAccessIterator, typename _Predicate>
      _RandomAccessIterator
!     __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,
  	    _Predicate __pred, random_access_iterator_tag)
      {
        typename iterator_traits<_RandomAccessIterator>::difference_type
*************** namespace std
*** 311,318 ****
        __glibcxx_function_requires(_EqualOpConcept<
  		typename iterator_traits<_InputIterator>::value_type, _Tp>)
        __glibcxx_requires_valid_range(__first, __last);
!       return std::find(__first, __last, __val,
! 		       std::__iterator_category(__first));
      }
  
    /**
--- 311,318 ----
        __glibcxx_function_requires(_EqualOpConcept<
  		typename iterator_traits<_InputIterator>::value_type, _Tp>)
        __glibcxx_requires_valid_range(__first, __last);
!       return std::__find(__first, __last, __val,
! 		         std::__iterator_category(__first));
      }
  
    /**
*************** namespace std
*** 333,340 ****
        __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
  	      typename iterator_traits<_InputIterator>::value_type>)
        __glibcxx_requires_valid_range(__first, __last);
!       return std::find_if(__first, __last, __pred,
! 			  std::__iterator_category(__first));
      }
  
    /**
--- 333,340 ----
        __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
  	      typename iterator_traits<_InputIterator>::value_type>)
        __glibcxx_requires_valid_range(__first, __last);
!       return std::__find_if(__first, __last, __pred,
! 			    std::__iterator_category(__first));
      }
  
    /**
// Copyright (C) 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING.  If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.

// 25.3.1 algorithms, find()

#include <algorithm>

using namespace std;

template<typename InputIterator, typename Tp>
    InputIterator
    find(InputIterator first, InputIterator last,
         const Tp& val, input_iterator_tag)
    { return first; }

int
main()
{
  input_iterator_tag a;
  int i;
  find(&i, &i, 1, a);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]