Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this noncompliant code example, the expression a++ is not evaluated, and the side effects in the expression are not executed.:

Code Block
bgColor#FFcccc
langc
int a = 14;
int b = sizeof(a++);

...

In this compliant solution, the variable a is incremented.:

Code Block
bgColor#ccccff
langc
int a = 14;
int b = sizeof(a);
a++;

...

This compliant solution avoids changing the value of the variable n used in the sizeof expression and instead increments it safely outside of it.:

Code Block
bgColor#ccccFF
langc
void f(size_t n) {
  size_t a = sizeof(int [n + 1]);
  ++n;

  size_t b = sizeof(int [n % 1 + 1]);
  ++n;
  /* ... */
}

...

Tool

Version

Checker

Description

Compass/ROSE

 

 

 

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

unexfct

Fully implemented.

    

LDRA tool suite

Include Page
LDRA_V
LDRA_V

54 S

Fully implemented

PRQA QA-C
Include Page
PRQA_V
PRQA_V
3307Fully implemented

...

 

...