[previous] 2853 [next] Suspicious: Implicit conversion to a signed integer type of insufficient size.
Conversion to signed

Dataflow analysis has identified a code construct which is suspicious. The code may be entirely safe but further investigation is advisable.

The value of an expression is being implicitly converted to a signed integer type. Examination of the immediate context suggests that the value of this expression could sometimes be too large to be represented in this type.

For example, in the code shown below, the value being assigned to sca will be '128' (which is unrepresentable) unless the parameter 'n' is greater than 0.


/*PRQA S 272,2017,2983,2986,3120,3195,3199,3203,3227,3408,3602 ++*/

void foo(int n)
{
   signed int  sia = 128;
   signed char sca;
   int         i;

   for (i = 0; i < n; ++i)
   {
      sia = sia - 10;
   }

   sca = sia;                     /* 2853 3756 */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents