Title
system_error and filesystem_error constructors taking a string may not be able to meet their postconditions
Status
c++20
Section
[syserr.syserr.members][fs.filesystem.error.members]
Submitter
Tim Song

Created on 2018-05-10.00:00:00 last changed 45 months ago

Messages

Date: 2019-01-20.16:20:00

Proposed resolution:

This wording is relative to N4727.

Drafting note: This contains a drive-by editorial change to use string_view for these postconditions rather than string.

  1. Edit [syserr.syserr.members] p1-4 as indicated:

    system_error(error_code ec, const string& what_arg);
    

    -1- Effects: Constructs an object of class system_error.

    -2- Postconditions: code() == ec and string_view(what()).find(what_arg.c_str()) != string_view::npos.

    system_error(error_code ec, const char* what_arg);
    

    -3- Effects: Constructs an object of class system_error.

    -4- Postconditions: code() == ec and string_view(what()).find(what_arg) != string_view::npos.

  2. Edit [syserr.syserr.members] p7-10 as indicated:

    system_error(int ev, const error_category& ecat, const std::string& what_arg);
    

    -7- Effects: Constructs an object of class system_error.

    -8- Postconditions: code() == error_code(ev, ecat) and string_view(what()).find(what_arg.c_str()) != string_view::npos.

    system_error(int ev, const error_category& ecat, const char* what_arg);
    

    -9- Effects: Constructs an object of class system_error.

    -10- Postconditions: code() == error_code(ev, ecat) and string_view(what()).find(what_arg) != string_view::npos.

  3. Edit [fs.filesystem_error.members] p2-4 as indicated:

    filesystem_error(const string& what_arg, error_code ec);
    

    -2- Postconditions:

    • code() == ec,
    • path1().empty() == true,
    • path2().empty() == true, and
    • string_view(what()).find(what_arg.c_str()) != string_view::npos.
    filesystem_error(const string& what_arg, const path& p1, error_code ec);
    

    -3- Postconditions:

    • code() == ec,
    • path1() returns a reference to the stored copy of p1,
    • path2().empty() == true, and
    • string_view(what()).find(what_arg.c_str()) != string_view::npos.
    filesystem_error(const string& what_arg, const path& p1, const path& p2, error_code ec);
    

    -4- Postconditions:

    • code() == ec,
    • path1() returns a reference to the stored copy of p1,
    • path2() returns a reference to the stored copy of p2,
    • string_view(what()).find(what_arg.c_str()) != string_view::npos.
Date: 2019-01-20.00:00:00

[ 2019-01-20 Reflector prioritization ]

Set Priority to 0 and status to Tentatively Ready

Date: 2018-05-10.00:00:00

The constructors of system_error and filesystem_error taking a std::string what_arg are specified to have a postcondition of string(what()).find(what_arg) != string::npos (or the equivalent with string_view). This is not possible if what_arg contains an embedded null character.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2019-02-26 17:40:23adminsetstatus: voting -> wp
2019-01-21 04:50:04adminsetstatus: ready -> voting
2019-01-20 16:20:00adminsetmessages: + msg10288
2019-01-20 16:20:00adminsetstatus: new -> ready
2018-05-10 20:42:31adminsetmessages: + msg9850
2018-05-10 00:00:00admincreate