This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Incrementing volatiles?


Bill Currie <bcurrie@tssc.co.nz> writes:

|> Andreas Schwab wrote:
|> > But that would be an awful special case.  All accesses to a volatile
|> > variable must be exactly as specified by the user, which means that they
|> > must never be moved, duplicated or combined.
|> 
|> Eh?  The user said `increment bar', not `grab bar, add one to it and
|> stuff the value back into bar'.  By your definition above, gcc is
|> broken.

Incrementing a variable *is* `read value, add one, write value'.  That's
how the standard defines it.  The only difference between `foo += 1' and
`foo = foo + 1' is that foo is evaluated only once, but this has nothing
to do with volatile, because that does not change the fact that there are
exactly two accesses to foo.

-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"
schwab@gnu.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]