------- Comment #4 from rearnsha at gcc dot gnu dot org  2010-07-29 16:29 
-------
Volatile alone won't prevent re-ordering of non-volatile memory operations. 
The volatile keyword only applies to that particular location (requiring the
compiler not to remove it, or change the number of accesses).

In this case you need to emit a memory barrier to prevent the compiler from
re-arranging the code.

A simple way to do this is to create an empty asm block that clobbers memory,
for example:

   asm  ("" : : : "memory");

this will cause the compiler to force out all pending memory operations before
the barrier and not to move later operations earlier.


-- 

rearnsha at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45127

Reply via email to