|
|
|
negative, so the operands of the comparison can never compare equal. Therefore, for full portability, the c should be declared as int . 5 EXAMPLE 2 In the fragment: char c; int i; long l; l = (c = i); the value of i is converted to the type of the assignment expression c = i , that is, char type. The value of the expression enclosed in parentheses is then converted to the type of the outer assignment expression, long int type. 6 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 c . 6.5.16.2 Compound assignment Constraints 1 For the operators += and -= only, either the left operand shall be a pointer to an object type and the right shall have integer type, or the left operand shall have qualified or 2 For the other operators, each operand shall have arithmetic type consistent with those Semantics 3 A compound assignment of the form E1 op = E2 differs from the simple assignment expression E1 = E1 op (E2) only in that the lvalue E1 is evaluated only once. §6.5.16.2 Language 93 |