how to cast away 'volatile'?

Andrew Haley aph@redhat.com
Tue Mar 13 16:58:00 GMT 2007


Ian Lance Taylor writes:
 > Andrew Haley <aph@redhat.com> writes:
 > 
 > > Ian Lance Taylor writes:
 > >  > 
 > >  > All objects shared between threads need to protected by a mutex, or by
 > >  > some other type of memory barrier.
 > > 
 > > It's an interesting contention -- that in GNU/Linux userspace there
 > > are essentially no legitimate uses for volatile.  Hmmmm...
 > 
 > There is one legitimate use: the C standard blesses the specific case
 > of "volatile sig_atomic_t".  A signal handler can reliably access a
 > variable of that type.
 > 
 > I don't think there is any other reason to use volatile in userspace.

I just thought of another one -- auto variables that are local to a
function that contains the invocation of a setjmp macro.

Andrew.



More information about the Gcc-help mailing list