698. system_error needs const char* constructors

Section: 22.5.7.1 [syserr.syserr.overview] Status: CD1 Submitter: Daniel Krügler Opened: 2007-06-24 Last modified: 2016-02-10

Priority: Not Prioritized

View all issues with CD1 status.

Discussion:

In 22.5.7.1 [syserr.syserr.overview] we have the class definition of std::system_error. In contrast to all exception classes, which are constructible with a what_arg string (see 22.2 [std.exceptions], or ios_base::failure in 30.5.3.1.1 [ios::failure]), only overloads with with const string& are possible. For consistency with the re-designed remaining exception classes this class should also provide c'tors which accept a const char* what_arg string.

Please note that this proposed addition makes sense even considering the given implementation hint for what(), because what_arg is required to be set as what_arg of the base class runtime_error, which now has the additional c'tor overload accepting a const char*.

Proposed resolution:

This proposed wording assumes issue 832 has been accepted and applied to the working paper.

Change 22.5.7.1 [syserr.syserr.overview] Class system_error overview, as indicated:

public:
  system_error(error_code ec, const string& what_arg);
  system_error(error_code ec, const char* what_arg);
  system_error(error_code ec);
  system_error(int ev, const error_category* ecat,
      const string& what_arg);
  system_error(int ev, const error_category* ecat,
      const char* what_arg);
  system_error(int ev, const error_category* ecat);

To 22.5.7.2 [syserr.syserr.members] Class system_error members add:

system_error(error_code ec, const char* what_arg);

Effects: Constructs an object of class system_error.

Postconditions: code() == ec and strcmp(runtime_error::what(), what_arg) == 0.

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

Effects: Constructs an object of class system_error.

Postconditions: code() == error_code(ev, ecat) and strcmp(runtime_error::what(), what_arg) == 0.