https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110807
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- I think this is the same warning that causes libstdc++ testsuite failures when testing with --target_board=unix/-D_GLIBCXX_DEBUG FAIL: 23_containers/vector/bool/swap.cc (test for excess errors) I thought I'd already reported that, but I can't find it. The library allocates space for N elements then copies n elements: vector(const vector& __x) : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator())) { _M_initialize(__x.size()); _M_copy_aligned(__x.begin(), __x.end(), begin()); } We probably have the usual problem that GCC thinks allocating memory might alter __x because it's a global, and so in theory (but never in practice) the program could replace operator new with something insane that modifies the global. I tried changing the constructor to: const_iterator __xbegin = __x.begin(), __xend = __x.end(); _M_initialize(__x.size()); _M_copy_aligned(__xbegin, __xend, begin()); That fixes the library test FAILs, but not the case in this bug report.