First of all, I understand that this is a requirement imposed by the Standard. 
However, the requirement, in general, is valid only for iterators that do not
refer to any container.  This is not the case with iterators useful in
algorithms; the default value of such an iterator has no meaning.
Moreover, the implementation of the library has no obligation to check this
trait for every algorithm, and I suggest that this check should be removed. 
The code for std::lower_bound does not use this feature in a meaningful way,
and it is straightforward to fix.
The patch below, apart from fixing the problem, also replaces iterator with

  template<typename _ForwardIterator, typename _Tp>
    lower_bound(_ForwardIterator __first, _ForwardIterator __last,
                const _Tp& __val)
      typedef typename std:: iterator_traits<_ForwardIterator>::value_type
      typedef typename std:: iterator_traits<_ForwardIterator>::difference_type

      // concept requirements
      __glibcxx_function_requires(_LessThanOpConcept<_ValueType, _Tp>)
      __glibcxx_requires_partitioned_lower(__first, __last, __val);

      _DistanceType __len = std:: distance(__first, __last);
      _DistanceType __half;

      while (__len > 0)
        _ForwardIterator __middle ((__first));
          __half = __len >> 1;
          std::advance(__middle, __half);
          if (*__middle < __val)
              __first = __middle;
              __len = __len - __half - 1;
            __len = __half;
      return __first;

           Summary: lower_bound iterator must be default constructible
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: giecrilj at stegny dot 2a dot pl
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux

Reply via email to