Minor fixes in POP3 analyzer based on flycheck warnings

This also adds an implementation of unreachable() to use for default
cases where it shouldn't ever actually cause the default.
This commit is contained in:
Tim Wojtulewicz 2025-04-04 15:11:40 -07:00
parent 34ee136a3c
commit bde2dec685
3 changed files with 22 additions and 5 deletions

View file

@ -661,5 +661,20 @@ inline std::vector<std::wstring_view> split(const wchar_t* s, const wchar_t* del
return split(std::wstring_view(s), std::wstring_view(delim));
}
/**
* Implementation of std::unreachable. Once C++23 is supported this can be replaced with
* an alias. This implementation is taken from cppreference.
*/
[[noreturn]] inline void unreachable() {
// Uses compiler specific extensions if possible. Even if no extension is used,
// undefined behavior is still raised by an empty function body and the noreturn
// attribute.
#if defined(_MSC_VER) && ! defined(__clang__) // MSVC
__assume(false);
#else // GCC, Clang
__builtin_unreachable();
#endif
}
} // namespace util
} // namespace zeek