Make filesystem::path safe for self assignment
authorJonathan Wakely <jwakely@redhat.com>
Fri, 5 Apr 2019 16:56:14 +0000 (17:56 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 5 Apr 2019 16:56:14 +0000 (17:56 +0100)
commitd96f11a2720c8ddfc3d181b181cfaadd888323cd
treeafbf6b6816e29fd29cd900906f354e82fde3df91
parent10f26de9155b71a2bd5055060004420939cf7a2d
Make filesystem::path safe for self assignment

The standard says "If *this and p are the same object, has no effect."
Previously we ended up clearing the path.

* include/bits/fs_path.h (path::operator=(path&&)): Check for self
assignment.
* src/c++17/fs_path.cc (path::operator=(const path&)): Likewise.
* testsuite/27_io/filesystem/path/assign/copy.cc: Test self
assignment.

From-SVN: r270171
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fs_path.h
libstdc++-v3/src/c++17/fs_path.cc
libstdc++-v3/testsuite/27_io/filesystem/path/assign/copy.cc