gcc: Qualifiers implementation
1
1 4.10 Qualifiers
1 ===============
1
1 * 'What constitutes an access to an object that has
1 volatile-qualified type (C90 6.5.3, C99 and C11 6.7.3).'
1
1 Such an object is normally accessed by pointers and used for
1 accessing hardware. In most expressions, it is intuitively obvious
1 what is a read and what is a write. For example
1
1 volatile int *dst = SOMEVALUE;
1 volatile int *src = SOMEOTHERVALUE;
1 *dst = *src;
1
1 will cause a read of the volatile object pointed to by SRC and
1 store the value into the volatile object pointed to by DST. There
1 is no guarantee that these reads and writes are atomic, especially
1 for objects larger than 'int'.
1
1 However, if the volatile storage is not being modified, and the
1 value of the volatile storage is not used, then the situation is
1 less obvious. For example
1
1 volatile int *src = SOMEVALUE;
1 *src;
1
1 According to the C standard, such an expression is an rvalue whose
1 type is the unqualified version of its original type, i.e. 'int'.
1 Whether GCC interprets this as a read of the volatile object being
1 pointed to or only as a request to evaluate the expression for its
1 side effects depends on this type.
1
1 If it is a scalar type, or on most targets an aggregate type whose
1 only member object is of a scalar type, or a union type whose
1 member objects are of scalar types, the expression is interpreted
1 by GCC as a read of the volatile object; in the other cases, the
1 expression is only evaluated for its side effects.
1