C and C++


LANG.STRUCT.COMMA : Use of Comma Operator

Summary

A use of the comma (,) operator.

(Does not apply to uses of the comma separator.)

Properties

Class Name Use of Comma Operator
Significance style
Mnemonic LANG.STRUCT.COMMA
Categories
MisraC2023 MisraC2023:12.3 The comma operator should not be used
Misra2012 Misra2012:12.3 The comma operator should not be used
Misra2004 Misra2004:12.10 The comma operator shall not be used
AUTOSARC++14 AUTOSARC++14:M5-18-1 The comma operator shall not be used.
MisraC++2008 MisraC++2008:5-18-1 The comma operator shall not be used.
MisraC++2023 MisraC++2023:8.19.1 The comma operator should not be used
JSF++ JSF++:168 The comma operator shall not be used.
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default, and require the unnormalized C ASTs for the project. To enable them, add the following WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Use of Comma Operator"
Note that retaining the unnormalized ASTs will increase the disk space used to store the project representation, and may make the analysis take longer.

Example

int lang_struct_comma(int a, int b){         /* comma separator */
  int x,  y;                                 /* comma separator */

  x = (a++, a-b);    /* 'Use of Comma Operator' warning issued here */
  y = x;
  return y;
}

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.