Versions Compared

Key

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

...

Code Block
bgColor#ccccff
signed int si = INT_MIN;
unsigned int ui;
if ( (si < 0) || (si > UINT_MAX) ) {
  /* handle error condition */
}
else {
  ui = (unsigned int)si;  /* cast eliminates warning */
}

...

Tool

Version

Checker

Description

Section

Fortify SCA

Section

V. 5.0

 

Section

can detect violations of this rule with CERT C Rule Pack

Section

Compass/ROSE

 

 

Section

can detect violations of this rule. However, false warnings may be raised if limits.h is included

Section

Klocwork

Include Page
c:Klocwork_V
c:Klocwork_V
Section

PRECISION.LOSS

 

Section

Coverity Prevent

Include Page
c:Coverity_V
c:Coverity_V
Section

NEGATIVE_RETURNS

Section

can find array accesses, loop bounds, and other expressions that may contain dangerous implied integer conversions that would result in unexpected behavior

Section

Coverity Prevent

Include Page
c:Coverity_V
c:Coverity_V
Section

REVERSE_NEGATIVE

Section

can find instances where a negativity check occurs after the negative value has been used for something else

Section

Coverity Prevent

Include Page
c:Coverity_V
c:Coverity_V
Section

MISRA_CAST

Section

can find the instances where an integer expression is implicitly converted to a narrower integer type, or implicitly converting the signedness of an integer value or implicitly converting the type of a complex expression

...