Title
remove_filename() post condition is incorrect
Status
resolved
Section
[fs.path.modifiers]
Submitter
Eric Fiselier

Created on 2014-06-07.00:00:00 last changed 89 months ago

Messages

Date: 2017-07-17.16:58:47

Proposed resolution:

This wording is relative to N4606.

  1. Modify [fs.path.modifiers] as indicated:

    path& remove_filename();
    

    -5- PostconditionEffects: !has_filename()If this->compare(root_path()) == 0, then clear(). Otherwise, *this = parent_path()..

    -6- Returns: *this.

    -7- [Example:

    std::cout << path("/foo").remove_filename(); // outputs "/"
    std::cout << path("/").remove_filename(); // outputs ""
    

    end example]

Date: 2017-07-17.18:25:53

[ 2017-07, Toronto Thursday night issues processing ]

This was resolved by the adoption of P0492R2.

Date: 2017-07-15.00:00:00

[ 2017-07-14, Davis Herring comments ]

Changes in P0492R2 changed remove_filename() and has_filename() in such a fashion that the postcondition is now satisfied. (In the example in the issue description, "/foo" does gets mapped to "/", but path("/").has_filename() is false.)

Date: 2016-11-15.00:00:00

[ 2016-11-21, Beman comments ]

This issue is closely related to CD NB comments US 25, US 37, US 51, US 52, US 53, US 54, and US 60. The Filesystem SG in Issaquah recommended that these all be handled together, as they all revolve around the exact meaning of "filename" and path decomposition.

Date: 2016-10-15.00:00:00

[ 2016-10-16, Eric reopens and provides improved wording ]

The suggested PR is incorrect. root_path() removes redundant directory separators.

Therefore the condition *this == root_path() will fail for "//foo///" because root_path() returns "//foo/". However using path::compare instead would solve this problem.

Date: 2016-10-16.11:32:37

[ 2016-08 Chicago ]

Wed AM: Move to Tentatively Ready

Previous resolution [SUPERSEDED]:

  path& remove_filename();

Postcondition: !has_filename().

Effects: If *this == root_path(), then clear(). Otherwise, *this = parent_path().

Returns: *this.

[Example:

      std::cout << path("/foo").remove_filename();  // outputs "/"
      std::cout << path("/").remove_filename();     // outputs ""
    

—end example]

Date: 2016-04-16.04:56:37

[ 2016-04, Issues Telecon ]

There was concern that the effects wording is not right. Jonathan provided updated wording.

Previous resolution [SUPERSEDED]:

    path& remove_filename();
  

Postcondition: !has_filename().

Effects: *this = parent_path(), except that if parent_path() == root_path(), clear().

Returns: *this.

[Example:

        std::cout << path("/foo").remove_filename();  // outputs "/"
        std::cout << path("/").remove_filename();     // outputs ""
      

—end example]

Date: 2016-08-06.21:31:18

[ 2016-04 Issue updated to address the C++ Working Paper. Previously addressed File System TS ]

Date: 2014-06-17.00:00:00

[ 2014-06-17 Rapperswil LWG will investigate issue at a subsequent meeting. ]

Date: 2014-06-08.00:00:00

[ 2014-06-08 Beman supplies an Effects: element. ]

Date: 2016-04-10.22:23:37

remove_filename() specifies !has_filename() as the post condition. This post condition is not correct. For example the path "/foo" has a filename of "foo". If we remove the filename we get "/", and "/" has a filename of "/".

History
Date User Action Args
2017-07-17 16:58:47adminsetmessages: + msg9432
2017-07-16 20:11:05adminsetmessages: + msg9415
2017-07-16 20:11:05adminsetstatus: open -> resolved
2016-11-26 14:41:57adminsetmessages: + msg8683
2016-10-16 11:32:37adminsetmessages: + msg8568
2016-10-16 11:32:37adminsetstatus: ready -> open
2016-08-04 02:52:49adminsetmessages: + msg8379
2016-08-04 02:52:49adminsetstatus: new -> ready
2016-04-16 04:56:37adminsetmessages: + msg8061
2016-04-10 22:23:37adminsetmessages: + msg8039
2016-01-28 01:00:35adminsetmessages: + msg7921
2016-01-28 01:00:35adminsetmessages: + msg7920
2016-01-28 01:00:35adminsetmessages: + msg7919
2014-06-07 00:00:00admincreate