Title
Non-existing path::native_string() in filesystem_error::what() specification
Status
c++20
Section
[fs.filesystem.error.members]
Submitter
Daniel Krügler

Created on 2017-05-22.00:00:00 last changed 46 months ago

Messages

Date: 2017-07-12.01:30:31

Proposed resolution:

This wording is relative to N4659.

  1. Edit [filesystem_error.members] as indicated:

    const char* what() const noexcept override;
    

    -7- Returns: A string containing runtime_error::what(). The exact format is unspecified. Implementations are encouraged but not required to include path1.native_string() if not empty, path2.native_string() if not empty, and system_error::what() stringsthe system_error::what() string and the pathnames of path1 and path2 in the native format in the returned string.

Date: 2017-07-12.01:30:31

[ 2017-07 Toronto Monday issue prioritization ]

Priority 0; move to Ready

Date: 2017-05-15.00:00:00

[ 2017-05-25, Jonathan comments and suggests an alternative resolution ]

The revised wording changes leave it up to the implementation which of the native format observers to use. The "if not empty" seems redundant, because if the path is empty then there's nothing to include anyway, but the proposed resolution preserves it.

Date: 2017-05-27.08:42:18

As pointed out by Jonathan Wakely and Bo Persson, [filesystem_error.members]/7 refers to a non-existing function path::native_string:

Returns: A string containing runtime_error::what(). The exact format is unspecified. Implementations are encouraged but not required to include path1.native_string() if not empty, path2.native_string() if not empty, and system_error::what() strings in the returned string.

Existing implementations differ, as Jonathan also determined:

  • Boost.Filesystem uses path::string().

  • Libstdc++ uses path::string().

  • MSVC++/Dinkumware uses path::u8string().

  • It seems that libc++ doesn't include the paths in what().

We've had native_string() in the spec since N3239 (where it already didn't match any existing path function at that time).

Before that it was file_string() in N1975 (within that specification path was a template that was parametrized in the character type).

Since it can't be path::native() because that might be the wrong type, one of path::string() or path::u8string() seems appropriate.

Albeit the wording is just a non-binding encouragement to implementations, the decision on this matter should not be considered editorially due to the existing implementation variance. Any official resolution of the current state could cause a reconsideration of existing implementations, and therefore it should be documented.

Previous resolution [SUPERSEDED]:

This wording is relative to N4659.

  1. Edit [filesystem_error.members] as indicated:

    const char* what() const noexcept override;
    

    -7- Returns: A string containing runtime_error::what(). The exact format is unspecified. Implementations are encouraged but not required to include path1.native_string() if not empty, path2.native_string() if not empty, and system_error::what() strings in the returned string.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2017-11-13 19:01:36adminsetstatus: voting -> wp
2017-10-17 18:34:55adminsetstatus: ready -> voting
2017-07-12 01:30:31adminsetmessages: + msg9333
2017-07-12 01:30:31adminsetstatus: new -> ready
2017-05-27 08:42:18adminsetmessages: + msg9187
2017-05-22 18:12:26adminsetmessages: + msg9186
2017-05-22 00:00:00admincreate