https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110060
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note you can reduce main to just: ``` int main() { std::vector<int> v(5); const std::vector<int> w(1); v.resize(1); // v.insert(v.begin(), 0); //v.insert(v.begin(), 1, 0); // v.insert(v.begin(), w.begin(), w.end()); v = w; return 0; } ``` And get the warning still at -O2. With the above main in .optimized we get: ``` MEM[(struct _Vector_base *)&w]._M_impl.D.25239._M_start = _53; _46 = _53 + 4; MEM[(struct _Vector_base *)&w]._M_impl.D.25239._M_end_of_storage = _46; *_53 = 0; w.D.25935._M_impl.D.25239._M_finish = _46; v.D.25935._M_impl.D.25239._M_finish = __first_33; __xlen_82 = std::vector<int>::size (&w); if (__xlen_82 > 5) goto <bb 4>; [33.00%] else goto <bb 10>; [67.00%] ``` std::vector<int>::size is literally just: ``` movq 8(%rdi), %rax subq (%rdi), %rax sarq $2, %rax ret ``` So that is definitely an issue there.