Previous Table of Contents "New C Standard" commentary
1296 One of the following shall hold:94)
1297 the left operand has qualified or unqualified arithmetic type and the right has arithmetic type;
1298 the left operand has a qualified or unqualified version of a structure or union type compatible with the type of the right;
1299 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;
1300
one operand is a pointer to an object or incomplete type and
the other is a pointer to a qualified or unqualified version of
1301 the left operand is a pointer and the right is a null pointer constant;
1302
or the left operand has type
1303
In simple assignment (
1304 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;
1305 otherwise, the behavior is undefined.
1306 EXAMPLE 1 In the program fragment
int f(void);
char c;
/* ... */
if ((c = f()) == -1)
/* ... */
the
1307
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
1308 EXAMPLE 2 In the fragment:
char c;
int i;
long l;
l = (c = i);
the value of
1309 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: 2008-01-30 02:39:43
The text from WG14/N1256 is copyright © ISO