This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization of conditional access to globals: thread-unsafe?
Richard Guenther writes:
> On 10/28/07, Erik Trulsson <ertr1013@student.uu.se> wrote:
> > Unfortunately it seems that the POSIX standard for threads say that as long
> > as access to a shared variable is protected by a mutex there is no need to
> > use 'volatile'.
>
> Which is a very unpracticable say, as it essentially would force the compiler
> to assume every variable is protected by a mutex (how should it prove
> otherwise?)
It's not as bad as you might think.
The compiler consequences of adopting the N2334 memory model proposal
are summarized here:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2338.html
Andrew.