Andrew Giese
2018-09-23 23:38:29 UTC
C++20 draft N4762 [dcl.attr.contract.check] seems contradictory to me.
It appears to simultaneously state that handling contract violations is
implementation-defined, but also that a user-provided violation handler is
possible.
Here are the relevant snippets:
The violation handler of a program is a function of type ânoexceptopt
Later, we see the following;
If a user-provided violation handler exits by throwing an exception and a
seems to imply that it's possible for a user to provide one, when the
previous paragraph suggests it's not possible.
Is this an issue with the standard wording?
It appears to simultaneously state that handling contract violations is
implementation-defined, but also that a user-provided violation handler is
possible.
Here are the relevant snippets:
The violation handler of a program is a function of type ânoexceptopt
function of (lvalue reference to const
std::contract_violation) returning voidâ, and is specified in an
implementation-defined manner. The
violation handler is invoked when the predicate of a checked contract
evaluates to false (called a contract
violation). There should be no programmatic way of setting or modifying
the violation handler. It is
implementation-defined how the violation handler is established for a
program and how the std::contract_-
violation (16.8.2) argument value is set, except as specified below.
The "as specified below" doesn't quite exist I think.std::contract_violation) returning voidâ, and is specified in an
implementation-defined manner. The
violation handler is invoked when the predicate of a checked contract
evaluates to false (called a contract
violation). There should be no programmatic way of setting or modifying
the violation handler. It is
implementation-defined how the violation handler is established for a
program and how the std::contract_-
violation (16.8.2) argument value is set, except as specified below.
Later, we see the following;
If a user-provided violation handler exits by throwing an exception and a
contract is violated on a call to a
function with a non-throwing exception specification, then the behavior is
as if the exception escaped the
function body.
This is the first and only mention of a user-provided violation handler. Itfunction with a non-throwing exception specification, then the behavior is
as if the exception escaped the
function body.
seems to imply that it's possible for a user to provide one, when the
previous paragraph suggests it's not possible.
Is this an issue with the standard wording?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.