Hi all,

one area where the Linux kernel people are unhappy with C's
memory model is where they now have to use the READ_ONCE,
WRITE_ONCE macros.  These are cases where they do not want
a compiler to duplicate a load, e.g. to reload a value
later because registers were not available to cache it.

Or similar, where a compiler produces two writes to
the same object where the source has only one or
invents a write where none existed, e.g. by turning
a conditional write after a read in an unconditional
one.

General, it seems compilers currently do not do this. 

One could alreay use volatile and then the C standard
would guarantee that there are exactly as many accesses
as the source code implies, but this is too strong,
because combining multiple reads into one and caching
the value or dead store elimination would still be ok.

The question is whether there are cases where GCC (or
C compilers in general) do such things?   Or if not,
where this would be desirable?   In other words: 
Would it be a ok to strengthen the requirements
here?


Martin

Reply via email to