[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 */
}


MISRA-C:2004 Rules applicable to message 2853:

Rule  3.1  (Required) All usage of implementation-defined behaviour shall be documented.


See also:

QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents