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

A definite anomaly has been detected. A conversion to a signed type is being performed but examination of the context indicates that the value being converted is always too large to be represented in this type. The result will be implementation-defined.

For example, an object of type signed char can usually only represent values in the range -128 to 127. In the code below, it can be seen that in each case, the value of the expression being assigned to sca is outside this range.


/*PRQA S 273,1278,2017,2982,2983,2984,2986,3120,3195,3198,3199,3203,3227,3408,3602 ++*/

void foo(signed int sia, unsigned int uia)
{
    signed char sca;

    if (sia < -128)
    {
        sca = sia;     /* 2851 3756 */
    }

    if (uia > 127u)
    {
        sca = uia;     /* 2851 3767 */
    }
}

See also:

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