https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99402

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> You should be using __base_dist.second, no?

No, it's not that simple. I don't understand how this code is meant to work,
but this can't be right:

      if (this->_M_is_begin())
        {
          if (__rhs._M_is_before_begin())
            return std::make_pair(-1, __dp_exact);

          if (__rhs._M_is_end())
            return __seq_dist;

          return std::make_pair(__seq_dist.first,
                                __seq_dist.second == __dp_exact
                                ? __dp_sign_max_size : __seq_dist.second);
        }

We can't use __seq_dist.first as the distance, because we have already
established that __rhs is not the end iterator, so it must be before the end.
And so the distance we're trying to find must be less than __seq_dist.first.

Reply via email to