On Mon, Jun 19, 2023 at 01:05:36PM +0200, Jan Hubicka via Gcc-patches wrote:
> -     if (max_size() - size() < __n)
> -       __throw_length_error(__N(__s));
> +     const size_type __max_size = max_size();
> +     // On 64bit systems vectors can not reach overflow by growing
> +     // by small sizes; before this happens, we will run out of memory.
> +     if (__builtin_constant_p(__n)
> +         && __builtin_constant_p(__max_size)
> +         && sizeof(ptrdiff_t) >= 8
> +         && __max_size * sizeof(_Tp) >= ((ptrdiff_t)1 << 60)

Isn't there a risk of overlow in the __max_size * sizeof(_Tp) computation?

        Jakub

Reply via email to