https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89117
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |9.0 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Author: redi Date: Wed Jan 30 23:18:22 2019 New Revision: 268406 URL: https://gcc.gnu.org/viewcvs?rev=268406&root=gcc&view=rev Log: PR libstdc++/89117 fix path::replace_extension("") case Previously the operator+=(extension) call would have re-parsed the path and recreated the components with the right extension. Since optimising it to not re-parse the whole string, we need to actually remove the extension from the final filename before appending anything to it, and append the dot to that final component too. PR libstdc++/89117 * src/c++17/fs_path.cc (path::replace_extension): Erase extension from final component as well as from _M_pathname. Append the dot using operator+= instead of only to _M_pathname. (path::_M_find_extension): Reformat slightly. * testsuite/27_io/filesystem/path/modifiers/replace_extension.cc: Add more test cases. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/src/c++17/fs_path.cc trunk/libstdc++-v3/testsuite/27_io/filesystem/path/modifiers/replace_extension.cc --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- Fixed, thanks for the report.