
On Fri, Dec 30, 2011 at 12:44 PM, Mathias Gaunard <mathias.gaunard@ens-lyon.org> wrote:
On 12/30/2011 02:48 PM, Beman Dawes wrote:
Class path locale initialization has suffered from a data race for several releases. See https://svn.boost.org/trac/boost/ticket/6320 for an example of code that suffers as a result.
The problem was introduced when locale initialization was changed from namespace scope initialization to function scope initialization. For Windows and Mac OS X, the fix is simply to change back to namespace scope initialization.
For non-BSD based POSIX systems such as Linux, the problem is more complex. These system need std::locale(""), "the locale-specific native environment".
From what you're saying, function-scope static initialization is only required on Linux.
That seems the easiest and most robust solution, particularly if class path continues to throw on locale("") errors.
Then you say that the problem is that function-scope static initialization is not thread-safe.
But function-scope static initalization is thread-safe with conforming C++11 compilers, and has been thread-safe with GCC and other compilers that follow the Itanium ABI for a fairly long time.
So the problem seems to be non-existent.
What about other compilers on Linux, like Intel and Clang? Any clue? --Beman