Skip to content

Commit 23b8975

Browse files
committed
Add more thorough description of unexpected specifications
1 parent eb56cc0 commit 23b8975

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cpp/common/src/codingstandards/cpp/exceptions/ExceptionFlow.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,14 @@ class FunctionCallThrowingExpr extends FunctionCall, ThrowingExpr {
318318
target = getTarget() and
319319
result = getAFunctionThrownType(target, _) and
320320
// [expect.spec] states that throwing an exception type that is prohibited
321-
// by the specification will result in the program terminating. We therefore
321+
// by the specification will result in the program terminating, unless
322+
// a custom `unexpected_handler` is registered that throws an exception type
323+
// which is compatible with the dynamic exception specification, or the
324+
// dynamic exception specification lists `std::bad_exception`, in which case
325+
// a `std::bad_exception` is thrown.
326+
// As dynamic exception specifications and the `unexpected_handler` are both
327+
// deprecated in C++14 and removed in C++17, we assume a default
328+
// `std::unexpected` handler that calls `std::terminate` and therefore
322329
// do not propagate such exceptions to the call sites for the function.
323330
not (
324331
hasDynamicExceptionSpecification(target) and

0 commit comments

Comments
 (0)