Title
system_error::system_error(error_code ec) not explicit
Status
new
Section
[syserr.syserr.members]
Submitter
Peter Dimov

Created on 2018-10-02.00:00:00, last changed 2018-10-06.11:25:03.

Messages

Date: 2018-10-06.11:25:03

Proposed resolution:

This wording is relative to N4762.

  1. Change [syserr.syserr.overview] p2, class system_error synopsis, as indicated

    namespace std {
      class system_error : public runtime_error {
      public:
        system_error(error_code ec, const string& what_arg);
        system_error(error_code ec, const char* what_arg);
        explicit 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);
        const error_code& code() const noexcept;
        const char* what() const noexcept override;
      };
    }
    
  2. Change [syserr.syserr.members] as indicated

    explicit system_error(error_code ec);
    

    -5- Effects: […]

    -6- Ensures: […]

Date: 2018-10-02.00:00:00

The constructor for std::system_error taking a single argument of type std::error_code is not marked explicit, which allows implicit conversions from error_code to system_error. I think that this is an oversight and not intentional, and that we should make this constructor explicit.

History
Date User Action Args
2018-10-06 11:25:03adminsetmessages: + msg10160
2018-10-02 00:00:00admincreate