glog icon indicating copy to clipboard operation
glog copied to clipboard

NullStream constructor and deconstructor not optimized away with GOOGLE_STRIP_LOG

Open JensHuthmann opened this issue 2 years ago • 1 comments

When compiling with gcc 13.1 (and other version) and using GOOGLE_STRIP_LOG the output gets optimized away as expected. However, the constructor and deconstruction calls of NullStream() are left over in the compiled program.

I copied together from 3a0d4d22c5ae0b9a2216988411cfa6bf860cc372 with a cmake -DCMAKE_BUILD_TYPE=Release .. generated output.

Link to compiler explorer See line 518 in compiler output

JensHuthmann avatar Jun 22 '23 02:06 JensHuthmann

Good catch!

After looking into the issue, I believe something like this could work. NullStream should probably not derive from LogMessage::LogStream to allow the compiler to optimize the corresponding symbols away.

sergiud avatar Dec 21 '23 23:12 sergiud