This replaces two implicit conversions from ptrdiff_t to size_t with
explicit conversions that include unreachable hints for the ptrdiff_t
value not being negative.
libstdc++-v3/ChangeLog:
* include/bits/stl_vector.h (~_Vector_base): Add unreachable
hint for negative capacity and cast to size_t explicitly.
* include/bits/vector.tcc (vector::_M_realloc_append): Use
size() instead of end() - begin().
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com>
_GLIBCXX20_CONSTEXPR
~_Vector_base() _GLIBCXX_NOEXCEPT
{
- _M_deallocate(_M_impl._M_start,
- _M_impl._M_end_of_storage - _M_impl._M_start);
+ ptrdiff_t __n = _M_impl._M_end_of_storage - _M_impl._M_start;
+ if (__n < 0)
+ __builtin_unreachable();
+ _M_deallocate(_M_impl._M_start, size_t(__n));
}
public:
__builtin_unreachable();
pointer __old_start = this->_M_impl._M_start;
pointer __old_finish = this->_M_impl._M_finish;
- const size_type __elems = end() - begin();
+ const size_type __elems = size();
pointer __new_start(this->_M_allocate(__len));
pointer __new_finish(__new_start);