MISRA C++:2023 Rule 8.19.1
Description
Rule Definition
The comma operator should 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 or initializations, or when you use a comma as the fold operator within a fold expression.
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: Advisory |
Version History
Introduced in R2024b