Heads-up: volatile and C++
Marcin Dalecki
martin@dalecki.de
Fri Apr 15 04:39:00 GMT 2005
On 2005-04-15, at 01:10, Richard Henderson wrote:
> On Thu, Apr 14, 2005 at 11:30:20PM +0200, Jason Merrill wrote:
>> Consider Double-Checked Locking
>> (http://www.cs.umd.edu/~pugh/java/memoryModel/
>> DoubleCheckedLocking.html).
>> I used DCL with explicit memory barriers to implement thread-safe
>> initialization of function-local statics
>> (libstdc++-v3/libsupc++/guard.cc). The proposed change to volatile
>> semantics would allow me to write it more simply, by just making the
>> initialized flag volatile. Yes, volatile would be stronger than is
>> actually necessary for DCLP, but I don't have to use it if I want
>> finer-grained control over the synchronization.
>
> Is there any reason to want to overload volatile for this, rather than
>
> template<classname T> T acquire(T *ptr);
> template<classname T> void release(T *ptr, T val);
>
> where the functions do the indirection plus the memory ordering?
Templates are a no-go for a well known and well defined subset for C++
for embedded programming known commonly as well embedded C++.
Actually speaking about embedded C++. Well, it would be helpful
to have an option for the C++ frontend which would disallow
constructs prohibited by it. If I only could find the time right now...
More information about the Gcc
mailing list