This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch] Fix libstdc++/11400
- From: Martin Sebor <sebor at roguewave dot com>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 29 Sep 2003 12:00:27 -0600
- Subject: Re: [Patch] Fix libstdc++/11400
- References: <3F756C2E.6090100@unitus.it>
Paolo Carlini wrote:
Hi,
the below, privately suggested by Nathan, is a minimal fix for the PR.
Seems the correct approach to me too! In fact
iterator_traits<>difference_type
is already used elsewhere in the same file for counting.
Tested x86-linux. Ok with everyone?
FWIW, this is still not 100% correct. __count - 1 is not guaranteed
to be defined or to return a type that's convertible to int. Imagine
struct Integral {
void operator- (int) { }
};
A safer fix would be to first convert __count to some integer type
and then decrement the copy:
typename iterator_traits<_ForwardIterator>::difference_type
__n = __count;
--__n;
Regards
Martin