2965. Non-existing path::native_string() in filesystem_error::what() specification

Section: 31.12.7.2 [fs.filesystem.error.members] Status: C++20 Submitter: Daniel Krügler Opened: 2017-05-22 Last modified: 2021-06-06

Priority: 0

View all other issues in [fs.filesystem.error.members].

View all issues with C++20 status.

Discussion:

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:

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.

[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.

[2017-07 Toronto Monday issue prioritization]

Priority 0; move to Ready

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.