We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An unexpected behavior of DLOG_ASSERT occured.
DLOG_ASSERT
#define NDEBUG #include <glog/logging.h> #include <assert.h> int main(int argc,char* argv[]) { FLAGS_logtostderr = 1; google::InitGoogleLogging(argv[0]); LOG(INFO) << "Hello,GLOG!"; DLOG(DFATAL) << "DLOG!"; DLOG_ASSERT(0); google::ShutdownGoogleLogging(); }
DLOG_ASSERT(0); should be compiled away to nothing for non-debug mode compiles while we got assertion failure.
DLOG_ASSERT(0);
I0922 10:14:15.887724 125488 demo.cc:15] Hello,GLOG! F0922 10:14:15.887872 125488 demo.cc:25] Assert failed: 0 *** Check failure stack trace: *** @ 0x7f94561461c3 google::LogMessage::Fail() @ 0x7f945614b25b google::LogMessage::SendToLog() @ 0x7f9456145ebf google::LogMessage::Flush() @ 0x7f94561466ef google::LogMessageFatal::~LogMessageFatal() @ 0x555c53928360 main @ 0x7f9455d710b3 __libc_start_main @ 0x555c539281ae _start Aborted (core dumped)
Is this a bug?
We take advantage of g++ macro expansion to compile the code.
g++ -E -P demo.cc > demo1.cc
DLOG_ASSERT(0); is converted to
static_cast<void>(0), true ? (void) 0 : static_cast<void>(0), !(!(0)) ? (void) 0 : google::LogMessageVoidify() & google::LogMessageFatal( "demo22.cc", 12).stream() << "Assert failed: " "0";
Are there missing parentheses around static_cast<void>(0), !(!(0)) ? (void) 0 : google::LogMessageVoidify() & google::LogMessageFatal( "demo22.cc", 12).stream() << "Assert failed: " "0"; ?
static_cast<void>(0), !(!(0)) ? (void) 0 : google::LogMessageVoidify() & google::LogMessageFatal( "demo22.cc", 12).stream() << "Assert failed: " "0";
The text was updated successfully, but these errors were encountered:
Good catch. Yes, there are parentheses missing around LOG_ASSERT.
LOG_ASSERT
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
An unexpected behavior of
DLOG_ASSERT
occured.DLOG_ASSERT(0);
should be compiled away to nothing for non-debug mode compiles while we got assertion failure.Is this a bug?
We take advantage of g++ macro expansion to compile the code.
DLOG_ASSERT(0);
is converted toAre there missing parentheses around
static_cast<void>(0), !(!(0)) ? (void) 0 : google::LogMessageVoidify() & google::LogMessageFatal( "demo22.cc", 12).stream() << "Assert failed: " "0";
?The text was updated successfully, but these errors were encountered: