parts/6.50.UnanticipatedExceptionsFromLibraryRoutines-HJW.md

6.50. Unanticipated Exceptions from Library Routines [HJW]

6.50.1 Applicability to language

The vulnerability as documented in ISO IEC 24772-1:2024 6.50 exists in C++. C++ supports both the exception mechanism and the error return mechanism. This clause assumes that any exceptions thrown by an external library are compatible with C++, otherwise the result is either implementation-defined or undefined (see Inter-language calling [DJS]).

When calling a function from a library whose source code is not visible, an unknown exception can be thrown. For such cases, the exception thrown from such a function is guaranteed to be caught by catch(...). See Ignored Error Status and Unhandled Exceptions [OYB].

6.50.2 Avoidance mechanisms for language users

To avoid the vulnerability or mitigate its ill effects, C++ software developers can: