-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
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:
Lines 446 to 450 in cbd091e
| #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:
Lines 1354 to 1357 in cbd091e
| [[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) | |
| } |
Lines 959 to 964 in cbd091e
| _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:
Lines 2992 to 2994 in cbd091e
| default: // Unrecognized bit pattern | |
| _CSTD abort(); | |
| } |
4. Places that handle robust WinAPI functions failures
Lines 97 to 99 in cbd091e
| 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:
Lines 891 to 893 in cbd091e
| [[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.