This is the mail archive of the
mailing list for the GCC project.
Re: Heads-up: volatile and C++
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
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....