volatile semantics
Paul Schlie
schlie@comcast.net
Sat Jul 23 02:15:00 GMT 2005
> Geoffrey Keating writes:
>
> int i;
- merely means: allocate and treat all references to the object as
referencing an unqualified int object, unless re-qualified within a
more local scope.
> without 'volatile', then this object cannot be modified unknown to the
> implementation, even if someone also writes '(*(volatile int *)&i) = 1'.
- merely means: treat the object being referenced as volatile qualified int
object (as the standard specifies, although it may result in an undefined
behavior, nothing more or less; as although the object may have not been
initially declared as being volatile, the program within the context of
this particular references has asserted that it must be treated as such,
thereby implying it's value must be assigned, and/or presumed to have been
possibly modified beyond the logical view of the program).
const, volatile, and restrict are all logically equivalent in this
regard; regardless of whether or not an object was declared as being
originally qualified, or subsequently declared as being so within the more
restricted scope of a function via it's parameter declaration, or single
reference via a qualified cast. Where although inconsistent references to
any single object may result in an undefined behavior, it should be clear
there's no value in attempting to rationalize any more creative less
consistent interpretation, as it will be no more correct, and only likely
unnecessarily complicating to both the implementation and programmer.
More information about the Gcc
mailing list