Incrementing volatiles?

Andreas Schwab schwab@issan.informatik.uni-dortmund.de
Wed Jul 15 03:14:00 GMT 1998


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



More information about the Gcc mailing list