Skip to main content

IAR Embedded Workbench for RL78 5.20

COMMA-overload (C++ only)

In this section:
Synopsis

Overloaded comma operator

Enabled by default

No

Severity/Certainty

Low/Low

lowlow.png
Full description

There are overloaded versions of the comma and logical conjunction operators. These have the semantics of function calls whose sequence point and ordering semantics are different from those of the built-in versions. Because it might not be clear at the point of use that these operators are overloaded, developers might be unaware which semantics apply. This check is identical to MISRAC++2008-5-2-11_b.

Coding standards
MISRA C++ 2008 5-2-11

(Required) The comma operator, && operator and the || operator shall not be overloaded.

Code examples

The following code example fails the check and will give a warning:

class C{
  bool x;
  bool operator,(bool other);
};

bool C::operator,(bool other){
  return x;
}

The following code example passes the check and will not give a warning about this issue:

class C{
  int x;
  int operator+(int other);
};

int C::operator+(int other){
  return x + other;
}