Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added a compliant example given in TS-17961

...

Code Block
bgColor#ccccff
langc
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
bgColor#ccccff
langc
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
bgColor#ccccff
langc
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
bgColor#ccccff
langc
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

...