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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jose Dapena Paz from comment #5)
> - The length is less than the possible pointer difference (checked with
> numeric_limits).

That seems too lenient to me, because for wchar_t, char16_t and char32_t the
maximum length that can actually exist in the program will be less than
PTRDIFF_MAX.

Our std::vector::max_size() uses this:

        // 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::max_size says we can).
        const size_t __diffmax
          = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp);

Reply via email to