Subject: Re: [boost] [filesystem] path thread safety fix impact on POSIX systems
From: Beman Dawes (bdawes_at_[hidden])
Date: 2011-12-31 18:20:54
On Sat, Dec 31, 2011 at 4:00 AM, Andrey Semashev
> On Friday, December 30, 2011 08:48:59 Beman Dawes wrote:
>> I can see two possible fixes:
>> (A) Use function scope locale initialization, using
>> boost/detail/lightweight_mutex.hpp to prevent data races.
>> (B) Use namespace scope locale initialization, defaulting the codecvt
>> facet to UTF-8 if std::locale("") throws.
>> The advantage of (B) is that path always initializes without throwing,
>> and that's what users seem to expect. The initialization is correct
>> for all those whose environments are configured correctly, and for
>> those uses who want UTF-8 even if their environments are
>> misconfigured. The POSIX users who prefer an exception on a
>> misconfigured environment can always add a std::locale("") at the
>> start of main().
>> Comments or opinions?
> Can't locale be initialized within a call_once initializer? This seems to be a
> natural solution for function-local static initializations.
That really shouldn't be necessary. Also, I'm trying to hold down
dependencies on other libraries, or anything that is C++11 only.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk