Boost logo

Boost :

Subject: Re: [boost] [filesystem] path thread safety fix impact on POSIX systems
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2011-12-31 04:00:49


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk