id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 11514,Thread-unsafe (or non-optimal in C++11) static initialization in boost/spirit/home/qi/numeric/detail/numeric_utils.hpp,Artem Tokmakov ,Joel de Guzman,"This file (it's the same in boost 1.58 which I have too): boost/spirit/home/qi/numeric/detail/numeric_utils.hpp has following code (similar in a couple of places): {{{ // Ensure n *= Radix will not overflow static T const max = (std::numeric_limits::max)(); static T const val = max / Radix; }}} Since static initialization is not thread-safe in Visual Studio (the one I'm using now is 2013 update 4), and because these variables are dependent on each other, this causes problems. Indeed, sometimes I get '''val''' initialized to 0, and other times to correct value. But even when ""magic statics"" are implemented, this will probably be not the most efficient implementation since a better one would be using, say, constexpr. There are couple of ways to fix this, and one with minimal changes (considering my minimal knowledge of boost constexpr machinery) would be: {{{ // ## Note how two variables are initialized independently. static T const max = (std::numeric_limits::max)(); static T const val = (std::numeric_limits::max)() / Radix; }}} Thanks! ",Bugs,closed,To Be Determined,spirit,Boost 1.58.0,Problem,fixed,unsafe initialization,