https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120029
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- The simplest fix is just: --- a/libstdc++-v3/src/c++17/fs_path.cc +++ b/libstdc++-v3/src/c++17/fs_path.cc @@ -880,6 +880,9 @@ path::operator+=(const path& p) return *this; } + if (&p == this) [[unlikely]] + return *this += p.native(); + #if _GLIBCXX_FILESYSTEM_IS_WINDOWS if (_M_type() == _Type::_Root_name || (_M_type() == _Type::_Filename && _M_pathname.size() == 1))