...
Code Block | ||||
---|---|---|---|---|
| ||||
do { /* ... */ } while ( foo(), (x = y) != 0) ; |
Compliant Example
This is a compliant example because the expression x = y is not used as the controlling expression of the while statement.
Code Block | ||||
---|---|---|---|---|
| ||||
do { /* ... */ } while ( x = y, p == q ) ;
|
Exceptions
EXP18-EXP1: Assignment can be used where the result of the assignment is itself a parameter to a comparison expression or relational expression.
...
Code Block | ||||
---|---|---|---|---|
| ||||
if ( ( x = y ) != 0 ) { /* ... */ } |
EXP18-EXP2: Assignment can be used where the expression consists of a single primary expression.
In this compliant example, the expression x=y is a single primary expression
Code Block | ||||
---|---|---|---|---|
| ||||
if ( ( x = y ) ) { /* ... */ } |
EXP18-EXP3: Assignment can be used in the above contexts if it occurs in a function argument or array index
In this compliant example, the expression x=y is used in a function argument
...