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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This doesn't help:

--- a/libstdc++-v3/include/bits/vector.tcc
+++ b/libstdc++-v3/include/bits/vector.tcc
@@ -936,15 +936,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
          *__position = __x;
          ++this->_M_impl._M_finish;
        }
+      else if (!this->_M_impl._M_start._M_p)
+       {
+         _Bit_pointer __q = this->_M_allocate(1);
+         iterator __i(std::__addressof(*__q), 0);
+         this->_M_impl._M_end_of_storage = __q + 1;
+         this->_M_impl._M_start = __i;
+         *__i = __x;
+         this->_M_impl._M_finish = ++__i;
+       }
       else
        {
          const size_type __len =
            _M_check_len(size_type(1), "vector<bool>::_M_insert_aux");
+         const iterator __begin = begin(), __end = end();
          _Bit_pointer __q = this->_M_allocate(__len);
          iterator __start(std::__addressof(*__q), 0);
-         iterator __i = _M_copy_aligned(begin(), __position, __start);
+         iterator __i = _M_copy_aligned(__begin, __position, __start);
          *__i++ = __x;
-         iterator __finish = std::copy(__position, end(), __i);
+         iterator __finish = std::copy(__position, __end, __i);
          this->_M_deallocate();
          this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
          this->_M_impl._M_start = __start;

Reply via email to