Boost logo

Boost :

Subject: Re: [boost] [thread] C++11 once_flag enabled when constexpr is not available
From: Jonathan Wakely (jwakely.boost_at_[hidden])
Date: 2013-03-05 08:03:36


On 5 March 2013 12:31, Vicente J. Botet Escriba wrote:
> Le 22/02/13 23:49, Andrey Semashev a écrit :
>>
>> Hi, Vicente!
>>
>> I see you applied my patch for call_once but you seem to forgot to disable
>> the
>> C++11 call_once interface when the compiler does not support constexpr.
>> Was
>> that intentional or you just missed it?
>>
>> Anyway, please find the patch attached.
>>
> Hi Andrey,
>
> In your patch you say
>
> +// For C++11 call_once interface the compiler MUST support constexpr.
> +// Otherwise once_flag would be initialized during dynamic initialization
> stage, which is not thread-safe.
>
>
> I'm not an expert on the C++11 wording. Could you elaborate why once_flag
> would be initialized during dynamic initialization stage?

A non-constexpr constructor is a function call, which cannot happen
during static initialization.


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