[Patch] Fix libstdc++/11400

Paolo Carlini pcarlini@unitus.it
Mon Sep 29 19:45:00 GMT 2003


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.



More information about the Libstdc++ mailing list