Heads-up: volatile and C++

Ken Raeburn raeburn@raeburn.org
Tue Apr 19 18:40:00 GMT 2005


On Apr 18, 2005, at 18:17, Robert Dewar wrote:
>> Is there anything in the language specifications (mainly C++ in this 
>> context, but is this an area where C and C++ are going to diverge, or 
>> is C likely to follow suit?) that prohibits spurious writes to a 
>> location?
>
> Surely the deal is that spurious writes are allowed unless the
> location is volatile. What other interpretation is possible?

That's what I thought.  So, unless the compiler (or language spec) is 
going to become thread-aware, any data to be shared across threads 
needs to be declared volatile, even if some other mechanism (like a 
mutex) is in use to do some synchronization.  Which means performance 
would be poor for any such data.

Which takes me back to: I think the compiler needs to be thread-aware.  
"Enhancing" the meaning of volatile, with the attendant performance 
issues, still doesn't seem adequate to allow for multithreaded 
programming, unless it's used *everywhere*, and performance shoots 
through the floor....



More information about the Gcc mailing list