https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109299
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- This is not a library bug. The library code is: basic_string(basic_string&& __str) noexcept : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator())) { if (__str._M_is_local()) { traits_type::copy(_M_local_buf, __str._M_local_buf, __str.length() + 1); } else { _M_data(__str._M_data()); _M_capacity(__str._M_allocated_capacity); } The warning is coming from the call to traits_type::copy which only happens if the string fits in the local buffer. Warning that it overflows the buffer is not helpful when we don't take that branch BECAUSE IT WOULD OVERFLOW THE BUFFER. These warnings need to be removed from the compiler.