You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
There is no definition of the term "user-provided violation handler". The term is unnecessary either way, a violation handler is always provided by the implementation, and so always "user-provided".
Additionally, why does it mention functions with non-throwing exception specification explicitly? What happens if a violation handler throws for a function with a throwing exception specifications?
The text was updated successfully, but these errors were encountered:
I agree with the concern about "user-provided" violation handler being undefined. Let's remove "user-provided".
Regarding your other concern: p5 encourages implementations to report the caller site as the source location of a precondition violation. The model here is that a precondition violation is a fault of the caller, not the callee, and therefore should be signalled in the caller. However, this model is, at face value, inconsistent with the expectation that a call to a non-throwing function never actually yields an exception. Therefore, the additional sentence ensures that for such a function, no exception escapes by placing the point-of-throw for the violation handler's exception into the body of the called function (which is "wrapped" by the noexcept on the function declaration and yields std::terminate).
These concerns don't apply for calls to functions with throwing exception specifications, so the exception thrown by the violation handler will happily bubble up the stack. (Whether the exception originated from calling the violation handler just before the call to the function with the violated precondition, or just after transferring control to it, is unobservable except for the source location, whose contents was made implementation-defined for exactly that reason.)
[dcl.attr.contract.check]p6:
There is no definition of the term "user-provided violation handler". The term is unnecessary either way, a violation handler is always provided by the implementation, and so always "user-provided".
Additionally, why does it mention functions with non-throwing exception specification explicitly? What happens if a violation handler throws for a function with a throwing exception specifications?
The text was updated successfully, but these errors were encountered: