diff --git a/src/glog/logging.h b/src/glog/logging.h index 170ab24e0..d9099774c 100644 --- a/src/glog/logging.h +++ b/src/glog/logging.h @@ -1333,7 +1333,7 @@ class GLOG_EXPORT LogMessage { LogMessage(const char* file, int line, const logging::internal::CheckOpString& result); - ~LogMessage(); + ~LogMessage() noexcept(false); // Flush a buffered message to the sink set in the constructor. Always // called by the destructor, it may also be called from elsewhere if diff --git a/src/logging.cc b/src/logging.cc index 5bd146c65..1e6291d5e 100644 --- a/src/logging.cc +++ b/src/logging.cc @@ -1723,8 +1723,9 @@ const char* LogMessage::fullname() const noexcept { return data_->fullname_; } const char* LogMessage::basename() const noexcept { return data_->basename_; } const LogMessageTime& LogMessage::time() const noexcept { return time_; } -LogMessage::~LogMessage() { +LogMessage::~LogMessage() noexcept(false) { Flush(); + bool fail = data_->severity_ == GLOG_FATAL && exit_on_dfatal; #ifdef GLOG_THREAD_LOCAL_STORAGE if (data_ == static_cast(&thread_msg_data)) { data_->~LogMessageData(); @@ -1735,7 +1736,10 @@ LogMessage::~LogMessage() { #else // !defined(GLOG_THREAD_LOCAL_STORAGE) delete allocated_; #endif // defined(GLOG_THREAD_LOCAL_STORAGE) -} + if (fail) { + Fail(); + } + } int LogMessage::preserved_errno() const { return data_->preserved_errno_; }