how to cast away 'volatile'?

Ian Lance Taylor iant@google.com
Tue Mar 13 16:06:00 GMT 2007


Andrew Haley <aph@redhat.com> writes:

> I didn't mean to suggest that volatile would necessarily be
> sufficient, but that it would be necessary.  Surely the compiler needs
> to know that the buffer is volatile, or what's to stop it re-ordering
> accesses around the asm statements that are the memory barriers?  I
> know that in gcc we add a memory clobber to such asms, but that isn't
> generally true.  OK, if we have POSIX threads we also have POSIX
> mutexes...

Right: you have to use a mutex for correctness, and the mutex has to
be magic.  And once you use a magic mutex, using volatile doesn't make
any difference.

Ian



More information about the Gcc-help mailing list