Closed bergjohan closed 1 month ago
Thanks for the report.
I don't have the proper setup locally, could you try this simple change:
auto timestamp =
boost::log::extract_or_default<boost::posix_time::ptime>(record["TimeStamp"], kInvalid);
and report if this fixes the build error ?
Thanks.
Yes, if I save both timestamp
and thread_id
by value it compiles successfully.
Describe your environment Ubuntu 24.04 LTS g++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0 Boost 1.83.0
Steps to reproduce
What is the expected behavior? Successful compilation
What is the actual behavior?
Additional context Note from https://www.boost.org/doc/libs/1_83_0/libs/log/doc/html/boost/log/extract_or_defaul_idm26363.html
Caution must be exercised if the default value is a temporary object. Because the function returns a reference, if the temporary object is destroyed, the reference may become dangling.
But afaict the default value is not a temporary object: https://github.com/open-telemetry/opentelemetry-cpp-contrib/blob/main/instrumentation/boost_log/src/sink.cc#L27
Is GCC wrong here?