Where don't call abort()
Since __fastfail is considered a superior way to fail, and nobody asked for specific behavior in most of the places where we call abort, let's replace abort() calls in:
1. Places that are not implementable in !_HAS_EXCEPTIONS mode:
|
#if _HAS_EXCEPTIONS
|
|
_Throw_bad_cast(); // lazy disallowed
|
|
#else
|
|
_CSTD abort(); // lazy disallowed
|
|
#endif
|
2. Places that seems like direct result of doing something wrong:
|
[[noreturn]] _Rx __stdcall _Function_not_callable(const _Move_only_function_data&, _Types&&...) noexcept {
|
|
_CSTD abort(); // Unlike std::function, move_only_function doesn't throw bad_function_call
|
|
// (N4950 [func.wrap.move.inv]/2)
|
|
}
|
|
_EXPORT_STD [[noreturn]] __forceinline void unreachable() noexcept /* strengthened */ {
|
|
_STL_UNREACHABLE;
|
|
#ifdef _DEBUG
|
|
_CSTD abort(); // likely to be called in debug mode, but can't be relied upon - already entered the UB territory
|
|
#endif // defined(_DEBUG)
|
|
}
|
3. Places that handle broken invariant:
|
default: // Unrecognized bit pattern
|
|
_CSTD abort();
|
|
}
|
4. Places that handle robust WinAPI functions failures
|
if (!_RENAME_WINDOWS_API(__std_init_once_begin_initialize)(&_Once._Opaque, 0, &_Pending, nullptr)) { |
|
_CSTD abort(); |
|
} |
5. Places that are inherently dead code paths and exist due to having to implement a virtual function:
|
[[noreturn]] const type_info& _Target_type() const noexcept override {
|
|
_CSTD abort(); // shouldn't be called, see GH-3888
|
|
}
|
What call instead
In headers we have the following alternatives:
_STL_REPORT_ERROR
_MSVC_STL_DOOM_FUNCTION
In separately compiled code we probably should directly call __fastfail.
Where don't call
abort()Since
__fastfailis considered a superior way to fail, and nobody asked for specific behavior in most of the places where we call abort, let's replaceabort()calls in:1. Places that are not implementable in
!_HAS_EXCEPTIONSmode:STL/stl/inc/xlocale
Lines 446 to 450 in cbd091e
2. Places that seems like direct result of doing something wrong:
STL/stl/inc/functional
Lines 1354 to 1357 in cbd091e
STL/stl/inc/utility
Lines 959 to 964 in cbd091e
3. Places that handle broken invariant:
STL/stl/inc/atomic
Lines 2992 to 2994 in cbd091e
4. Places that handle robust WinAPI functions failures
STL/stl/inc/xcall_once.h
Lines 97 to 99 in cbd091e
5. Places that are inherently dead code paths and exist due to having to implement a virtual function:
STL/stl/inc/functional
Lines 891 to 893 in cbd091e
What call instead
In headers we have the following alternatives:
_STL_REPORT_ERROR_MSVC_STL_DOOM_FUNCTIONIn separately compiled code we probably should directly call
__fastfail.