https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86274
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Known to work| |6.4.0 Keywords| |wrong-code Last reconfirmed| |2018-06-25 Component|libstdc++ |ipa CC| |marxin at gcc dot gnu.org Ever confirmed|0 |1 Summary|SEGFAULT when logging |[7/8/9 Regression] SEGFAULT |std::to_string(NAN) |when logging | |std::to_string(NAN) Known to fail| |6.4.0, 7.3.0, 8.1.0, 9.0 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Filip Matzner from comment #0) > 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()); There's no crash if BOOST_LOG_TRIVIAL(info) is replaced with std::cout, which suggests there's nothing wrong with the std::to_string code or the std::string constructor. It crashes with either the old or new std:string code. Either way, it crashes when calling __builtin_mcmcpy > } > > > When compiled with the following command: > g++ -std=c++17 -DBOOST_ALL_DYN_LINK -pthread -lboost_log -O3 test.cpp > > It crashes with SEGFAULT in std::string constructor: > > #0 0x0000555555556221 in std::char_traits<char>::copy (__n=3, > __s2=0x7fffffffd4e0 "nan", __s1=<optimized out>) at > /usr/include/c++/7/bits/char_traits.h:350 > > Note that the SEGFAULT does not happen with -O2, but only -O3. It crashes with -O2 -fipa-cp-clone Compiled with GCC 6 it doesn't crash. Compiled with GCC 7.1+ it crashes. Preprocessed with GCC 6 and compiled with GCC 7+ it crashes.