This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Fix libstdc++/11400


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]