1286 One of the following shall hold:94)
1287 the left operand has qualified or unqualified arithmetic type and the right has arithmetic type;
1288 the left operand has a qualified or unqualified version of a structure or union type compatible with the type of the right;
1289 both operands are pointers to qualified or unqualified versions of compatible types, and the type pointed to by the left has all the qualifiers of the type pointed to by the right;
1290
one operand is a pointer to an object or incomplete type and
the other is a pointer to a qualified or unqualified version of
1291 the left operand is a pointer and the right is a null pointer constant;
1292
or the left operand has type
1293
In simple assignment (
1294 If the value being stored in an object is read from another object that overlaps in any way the storage of the first object, then the overlap shall be exact and the two objects shall have qualified or unqualified versions of a compatible type;
1295 otherwise, the behavior is undefined.
1296 EXAMPLE 1 In the program fragment
int f(void);
char c;
/* ... */
if ((c = f()) == -1)
/* ... */
the
1297
94) The asymmetric appearance of these constraints with respect to
type qualifiers is due to the conversion (specified in 6.3.2.1) that
changes lvalues to the value of the expression
1298 EXAMPLE 2 In the fragment:
char c;
int i;
long l;
l = (c = i);
the value of
1299 EXAMPLE 3 Consider the fragment:
const char **cpp;
char *p;
const char c = 'A';
cpp = &p; // constraint violation
*cpp = &c; // valid
*p = 0; // valid
The first assignment is unsafe because it would allow the following
valid code to attempt to change the value of the const object
Next
Created at: 2005-06-29 02:19:00
The text from WG14/N1124 is copyright © ISO