Unverified Commit 5de62af6 authored by Tobias Hammer's avatar Tobias Hammer Committed by GitHub

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.
parent cbddab2f
...@@ -49,7 +49,9 @@ FMT_BEGIN_NAMESPACE ...@@ -49,7 +49,9 @@ FMT_BEGIN_NAMESPACE
namespace detail { namespace detail {
FMT_FUNC void assert_fail(const char* file, int line, const char* message) { 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 // Chosen instead of std::abort to satisfy Clang in CUDA mode during device
// code pass. // code pass.
std::terminate(); std::terminate();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment