Here is a cut down demo for a bug I found with C++ 2016. The program dies at runtime at the stream.imbue call. If the E function is not marked inline it works fine.
// Intel C++ 2016 locale imbue bug demo // Compiled with: // icl /Qstd=c++11 /Wall /Od imbue.cc #include <cstddef> #include <iomanip> #include <iostream> #include <sstream> #include <string>
inline // Works without inline std::string E( double const t, std::size_t w ) { std::cout << "E.1"<< std::endl; //////////// static auto np( new std::num_put< char > ); static std::locale const loc( std::locale(), np ); std::ostringstream stream; std::cout << "E.2"<< std::endl; //////////// stream.imbue( loc ); std::cout << "E.3"<< std::endl; //////////// stream << std::showpoint << std::setw( w ) << t; return stream.str(); }
int main() { std::cout << E( 0.01, 24ul ) << std::endl; }