https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90408
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=98265 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So now -O1, -O2 and -O3 produce the same code, most likely after r10-9646/r11-7940 . -Os just does not inline the constructor ( std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&) [complete object constructor]). So I think this is fixed in GCC 10.3 and GCC 11+.