This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch] Fix libstdc++/11400
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Martin Sebor <sebor at roguewave dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 29 Sep 2003 20:14:59 +0200
- Subject: Re: [Patch] Fix libstdc++/11400
- References: <3F756C2E.6090100@unitus.it> <3F78733B.70205@roguewave.com>
Martin Sebor wrote:
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;
I see... To be fair, I tried to keep the spirit of Nathan's original
suggestion in a minimal fix, hoping to find the time to return to the
issue later: actually, he had envisaged a more invasive fix,
avoiding completely the - 1, among other things.
Anyway, for the time being, I'm just testing and committing your
refinement.
Thanks!
Paolo.