971. Spurious diagnostic conversion function

Section: [syserr.errcode.nonmembers] Status: NAD Submitter: Beman Dawes Opened: 2009-01-19 Last modified: 2016-02-10

Priority: Not Prioritized

View all issues with NAD status.


Anthony Williams raised the question in c++std-lib-22987 "why is there std::make_error_code(std::errc)? What purpose does this serve?"

The function make_error_code(errc e) is not required, since make_error_condition(errc e) is the function that is needed for errc conversions. make_error_code(errc e) appears to be a holdover from my initial confusion over the distinction between POSIX and operating systems that conform to the POSIX spec.

[ Post Summit: ]

Recommend Review.

[ Batavia (2009-05): ]

The designer of the facility (Christopher Kohlhoff) strongly disagrees that there is an issue here, and especially disagrees with the proposed resolution. Bill would prefer to be conservative and not apply this proposed resolution. Move to Open, and recommend strong consideration for NAD status.

[ 2009-05-21 Beman adds: ]

My mistake. Christopher and Bill are correct and the issue should be NAD. The function is needed by users.

[ 2009-07-21 Christopher Kohlhoff adds rationale for make_error_code: ]

Users (and indeed library implementers) may need to use the errc codes in portable code. For example:

void do_foo(error_code& ec)
#if defined(_WIN32)
  // Windows implementation ...
#elif defined(linux)
  // Linux implementation ...
  // do_foo not supported on this platform
  ec = make_error_code(errc::not_supported);

[ 2009 Santa Cruz: ]

Moved to NAD.

Proposed resolution:

Change System error support 22.5 [syserr], Header <system_error> synopsis, as indicated:

error_code make_error_code(errc e);
error_condition make_error_condition(errc e);

Delete from Class error_code non-member functions [syserr.errcode.nonmembers]:

error_code make_error_code(errc e);

Returns: error_code(static_cast<int>(e), generic_category).