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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This seems to avoid the warning:

--- a/libstdc++-v3/include/bits/vector.tcc
+++ b/libstdc++-v3/include/bits/vector.tcc
@@ -926,9 +926,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
     vector<bool, _Alloc>::
     _M_reallocate(size_type __n)
     {
+      const const_iterator __begin = begin(), __end = end();
+      if ((__end - __begin) > __n)
+       __builtin_unreachable();
       _Bit_pointer __q = this->_M_allocate(__n);
       iterator __start(std::__addressof(*__q), 0);
-      iterator __finish(_M_copy_aligned(begin(), end(), __start));
+      iterator __finish(_M_copy_aligned(__begin, __end, __start));
       this->_M_deallocate();
       this->_M_impl._M_start = __start;
       this->_M_impl._M_finish = __finish;

Reply via email to