This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

698. system_error needs const char* constructors

Section: 19.5.8.1 [syserr.syserr.overview] Status: CD1 Submitter: Daniel Krügler Opened: 2007-06-24 Last modified: 2016-01-28

Priority: Not Prioritized

View all issues with CD1 status.

Discussion:

In 19.5.8.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 19.2 [std.exceptions], or ios_base::failure in [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(i) has been accepted and applied to the working paper.

Change 19.5.8.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 19.5.8.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.