2721. remove_all has incorrect post conditions

Section: 30.11.14.31 [fs.op.remove_all] Status: C++17 Submitter: Eric Fiselier Opened: 2016-05-28 Last modified: 2017-07-30

Priority: 3

View all issues with C++17 status.

Discussion:

The current post condition for remove_all(p, [...]) states:

Postcondition: !exists(p)

This is not correct when p is a symlink, since !exists(p) reads through the symlink. The postcondition should be changed to match that of remove which states !exists(symlink_status(p)).

[2016-06, Oulu — Eric clarifies the importance of the suggested change]

With the current post conditions remove_all(p) could just not remove dangling symlinks and still meet the post conditions.

Moved to Ready after Eric convinced the room.

Friday: status to Immediate

Proposed resolution:

This wording is relative to N4582.

  1. Change 30.11.14.31 [fs.op.remove_all] as indicated:

    uintmax_t remove_all(const path& p);
    uintmax_t remove_all(const path& p, error_code& ec) noexcept;
    

    -1- Effects: Recursively deletes the contents of p if it exists, then deletes file p itself, as if by POSIX remove().

    -2- [Note: A symbolic link is itself removed, rather than the file it resolves to being removed. — end note]

    -3- Postcondition: !exists(symlink_status(p)).