diff --git a/src/logging.cc b/src/logging.cc index 08b2ab387..78ca31f22 100644 --- a/src/logging.cc +++ b/src/logging.cc @@ -2541,8 +2541,11 @@ LogMessageFatal::LogMessageFatal(const char* file, int line, : LogMessage(file, line, result) {} LogMessageFatal::~LogMessageFatal() noexcept(false) { - Flush(); - LogMessage::Fail(); + // We really want [[noreturn]] on the destructor so the compiler can use it. + // We really just want to reuse the parent class's destructor since it has all + // the right logic in it. + LogMessage::~LogMessage(); + Fail(); } namespace logging { diff --git a/src/logging_unittest.cc b/src/logging_unittest.cc index 321f38fa3..e6a393af4 100644 --- a/src/logging_unittest.cc +++ b/src/logging_unittest.cc @@ -1586,3 +1586,9 @@ TEST(Logging, FatalThrow) { ScopedExit restore{restore_fail}; EXPECT_THROW({ LOG(FATAL) << "must throw to fail"; }, std::logic_error); } + +TEST(DeathLogging, ErrorMessage) { + ASSERT_DEATH({ LOG(FATAL) << "foo"; }, "Check failure stack trace"); + ASSERT_DEATH({ LOG_AT_LEVEL(google::LogSeverity::FATAL) << "foo"; }, + "Check failure stack trace"); +}