#13611 closed Bugs (invalid)
SEGFAULT when logging std::to_string(NAN)
Reported by: | Filip Matzner | Owned by: | Andrey Semashev |
---|---|---|---|
Milestone: | To Be Determined | Component: | log |
Version: | Boost 1.67.0 | Severity: | Problem |
Keywords: | Cc: | boost@… |
Description
Consider the following code:
#include <climits> #include <boost/log/trivial.hpp> int main() { BOOST_LOG_TRIVIAL(info) << std::to_string(std::numeric_limits<double>::quiet_NaN()); }
When compiled with:
g++ -std=c++17 -DBOOST_ALL_DYN_LINK -pthread -lboost_log -O3 test.cpp && ./a.out
It crashes with SEGFAULT. If I replace BOOST_LOG_TRIVIAL(info) with std::cout, it does not.
System:
[floop@pine /tmp ]$ g++ -v ... gcc version 8.1.1 20180531 (GCC) [floop@pine /tmp ]$ uname -a Linux pine 4.16.13-2-ARCH #1 SMP PREEMPT Fri Jun 1 18:46:11 UTC 2018 x86_64 GNU/Linux
Note that the SEGFAULT does not happen with clang++, but only g++. It also does not happen with -O2, but only -O3. It might also be a compiler bug, you will probably know better than me. :-)
Change History (3)
comment:1 by , 4 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:3 by , 4 years ago
Ok, thanks, reported here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86274
Note:
See TracTickets
for help on using tickets.
In order to compile the test I had to modify the compiler command line:
gdb shows that the crash is happening during
std::string
construction:This is definitely a compiler problem. Please, report to gcc devs: https://gcc.gnu.org/bugzilla/