asio-tr2 icon indicating copy to clipboard operation
asio-tr2 copied to clipboard

Overspecification? if (ec) throw system_error(ec, __func__);

Open jwakely opened this issue 9 years ago • 3 comments

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0112r0.html#err.report.sync says

error_code ec;
f(a1, a2, ..., aN, ec);
if (ec) throw system_error(ec, __func__);

It's not clear to me that using a different string to __func__ would be conforming.

jwakely avatar Oct 14 '15 21:10 jwakely

How about something like:

error_code ec;
f(a1, a2, ..., aN, ec);
if (ec) throw system_error(ec, S);

where S is an implementation-defined NTBS [Note: A possible value for S is func. --end note]

Or... can we make it even looser and simply use words to say: if ec is true then the function throws an exception that is catchable as system_error?

chriskohlhoff avatar Oct 14 '15 23:10 chriskohlhoff

I like the direction, but saying implementation-defined means implementations are required to document what strings are used in which places.

How about:

where S is a NTBS indicating where the exception was thrown [Note: A possible value for S is __func__. --end note]

jwakely avatar Oct 14 '15 23:10 jwakely

Fixed in b86f0dede9c671e27366d6d032206a4812da520e.

chriskohlhoff avatar Oct 16 '15 12:10 chriskohlhoff