This is the mail archive of the
mailing list for the GCC project.
Re: Optimization of conditional access to globals: thread-unsafe?
On Sun, Oct 28, 2007 at 01:10:00PM -0400, Robert Dewar wrote:
> Erik Trulsson wrote:
>> Unfortunately it seems that the POSIX standard for threads say that as
>> as access to a shared variable is protected by a mutex there is no need to
>> use 'volatile'.
> How does it say this, in some semantically precise way, or with hand
> waving as in this sentence.
I don't know. I don't have access to the POSIX standard itself so I have
to depend on other peoples description of what POSIX says. (Thus my use of
Everything I have found seem to agree that POSIX does not require the use of
>> This means that POSIX essentially defines certain behaviours that the C
>> standard left undefined.
> But does it do so precisely?
I doubt it.
Personally I suspect that "C + pthreads" is simply not well-defined
currently, and that almost every single program out there that uses pthreads
is depending on undefined behaviour. Taking a hard-line stance on that
seems unlikely to be very popular or useful, though.
<Insert your favourite quote here.>