type-qualifier: const restrict volatile
1467 Types other than pointer types derived from object or incomplete types shall not be restrict-qualified.
1468 The properties associated with qualified types are meaningful only for expressions that are lvalues.112)
1469
If the same qualifier appears more than once in the same
1470 If an attempt is made to modify an object defined with a const-qualified type through use of an lvalue with non-const-qualified type, the behavior is undefined.
1471 If an attempt is made to refer to an object defined with a volatile-qualified type through use of an lvalue with non-volatile-qualified type, the behavior is undefined.113)
1472 An object that has volatile-qualified type may be modified in ways unknown to the implementation or have other unknown side effects.
1473 Therefore any expression referring to such an object shall be evaluated strictly according to the rules of the abstract machine, as described in 5.1.2.3.
1474 Furthermore, at every sequence point the value last stored in the object shall agree with that prescribed by the abstract machine, except as modified by the unknown factors mentioned previously.114)
1475
112) The implementation may place a
1476 Moreover, the implementation need not allocate storage for such an object if its address is never used.
1477 113) This applies to those objects that behave as if they were defined with qualified types, even if they are never actually defined as objects in the program (such as an object at a memory-mapped input/output address).
1478 What constitutes an access to an object that has volatile-qualified type is implementation-defined.
1479 An object that is accessed through a restrict-qualified pointer has a special association with that pointer.
1480 This association, defined in 6.7.3.1 below, requires that all accesses to that object use, directly or indirectly, the value of that particular pointer.115)
1481
The intended use of the
1482 If the specification of an array type includes any type qualifiers, the element type is so-qualified, not the array type.
1483 If the specification of a function type includes any type qualifiers, the behavior is undefined.116)
1484 For two qualified types to be compatible, both shall have the identically qualified version of a compatible type;
1485 the order of type qualifiers within a list of specifiers or qualifiers does not affect the specified type.
1486 EXAMPLE 1 An object declared
extern const volatile int real_time_clock;
may be modifiable by hardware, but cannot be assigned to, incremented, or decremented.
1487 EXAMPLE 2 The following declarations and expressions illustrate the behavior when type qualifiers modify an aggregate type:
const struct s { int mem; } cs = { 1 };
struct s ncs; // the object ncs is modifiable
typedef int A[2][3];
const A a = {{4, 5, 6}, {7, 8, 9}}; // array of array of const int
int *pi;
const int *pci;
ncs = cs; // valid
cs = ncs; // violates modifiable lvalue constraint for =
pi = &ncs.mem; // valid
pi = &cs.mem; // violates type constraints for =
pci = &cs.mem; // valid
pi = a[0]; // invalid: a[0] has type "const int *"
1488
114) A
1489 Actions on objects so declared shall not be optimized out by an implementation or reordered except as permitted by the rules for evaluating expressions.
1490
115) For example, a statement that assigns a value returned by
1491
116) Both of these can occur through the use of
Next
Created at: 2005-06-29 02:19:01
The text from WG14/N1124 is copyright © ISO