MISRA C++:2008 Rule 5-18-1
The comma operator shall not be used
Description
Rule Definition
The comma operator shall not be used.
Rationale
The comma operator takes two operands. It evaluates the operators from left to right, discards the value of the left operand,and returns the value of the right operand. This operator has the lowest operator precedence. These properties make the use of the comma operator nonintuitive. For instance, consider this code:
array[i++,j] = 1
i++; array[j] = 1;
Polyspace Implementation
Polyspace® flags the use of comma operator. Violations are not raised when you use comma operator for function calls and initializations.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Expressions |
Category: Required |
Version History
Introduced in R2013b