mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-02 11:28:20 +00:00
Fix possible infinite recursion in FMT_ASSERT (#1744)
Use std::fprintf for assertion message output preventing infinite recursion when output to stderr is limited or broken.
This commit is contained in:
parent
cbddab2fe2
commit
5de62af604
@ -49,7 +49,9 @@ FMT_BEGIN_NAMESPACE
|
||||
namespace detail {
|
||||
|
||||
FMT_FUNC void assert_fail(const char* file, int line, const char* message) {
|
||||
print(stderr, "{}:{}: assertion failed: {}", file, line, message);
|
||||
// Use unchecked std::fprintf to avoid triggering another assertion when
|
||||
// writing to stderr fails
|
||||
std::fprintf(stderr, "%s:%d: assertion failed: %s", file, line, message);
|
||||
// Chosen instead of std::abort to satisfy Clang in CUDA mode during device
|
||||
// code pass.
|
||||
std::terminate();
|
||||
|
Loading…
Reference in New Issue
Block a user