================ @@ -0,0 +1,41 @@ +.. title:: clang-tidy - bugprone-unsafe-to-allow-exceptions + +bugprone-unsafe-to-allow-exceptions +=================================== + +Finds functions where throwing exceptions is unsafe but the function is still +marked as potentially throwing. Throwing exceptions from the following +functions can be problematic: + +* Destructors +* Move constructors +* Move assignment operators +* The ``main()`` functions +* ``swap()`` functions +* ``iter_swap()`` functions +* ``iter_move()`` functions + +A destructor throwing an exception may result in undefined behavior, resource +leaks or unexpected termination of the program. Throwing move constructor or +move assignment also may result in undefined behavior or resource leak. The +``swap()`` operations expected to be non throwing most of the cases and they +are always possible to implement in a non throwing way. Non throwing ``swap()`` +operations are also used to create move operations. A throwing ``main()`` +function also results in unexpected termination. + +The check finds any of these functions if it is marked with ``noexcept(false)`` +or ``throw(exception)``. This would indicate that the function is expected to ---------------- balazske wrote:
Purpose of this check is only to find if a specific function (where throwing exceptions is unsafe) is explicitly marked as throwing. If there is no exception spec the other checker `bugprone-exception-escape` can find if it throws exceptions (the problem is only if the function is marked as potentially throwing with an exception specification because then it is always considered as safe by that other checker even if throwing exception in that function may be unsafe). https://github.com/llvm/llvm-project/pull/176430 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
