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

--- Comment #7 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #5)
>        static size_type
>        _S_max_size(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
>        {
> -       const size_t __diffmax =
> __gnu_cxx::__numeric_traits<ptrdiff_t>::__max;
> +       // std::distance(begin(), end()) cannot be greater than PTRDIFF_MAX,
> +       // and realistically we can't store more than PTRDIFF_MAX/sizeof(T)
> +       // (even if std::allocator_traits<A>::max_size() says we can).
> +       const size_t __diffmax
> +         = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp);
>         const size_t __allocmax = _Alloc_traits::max_size(__a);
>         return (std::min)(__diffmax, __allocmax);
>        }

This looks like a more useful value for __diffmax indeed. And the standard even
seems ok with us doing that :-)

Reply via email to