From 1eac90daf1e7fc712f8635edcfe6548e040cbecd Mon Sep 17 00:00:00 2001 From: Sam Yates <halfflat@gmail.com> Date: Wed, 29 Jun 2016 12:53:32 +0200 Subject: [PATCH] Use cerr in preference to stderr for assertion message. * Finds an actual (possibly) reasonable use for std::endl. --- src/util/debug.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/debug.cpp b/src/util/debug.cpp index 21eca07d..a15ef5c6 100644 --- a/src/util/debug.cpp +++ b/src/util/debug.cpp @@ -1,12 +1,16 @@ -#include <cstdio> #include <cstdlib> +#include <iostream> #include "util/debug.hpp" bool nest::mc::util::failed_assertion(const char *assertion, const char *file, int line, const char *func) { - std::fprintf(stderr, "%s:%d %s: Assertion `%s' failed.\n", file, line, func, assertion); + // Explicit flush, as we can't assume default buffering semantics on stderr/cerr, + // and abort() mignt not flush streams. + + std::cerr << file << ':' << line << " " << func + << ": Assertion `" << assertion << "' failed." << std::endl; std::abort(); return false; } -- GitLab