[previous] 2922 [next] Apparent: Left shift operation on expression of unsigned type results in loss of high order bits.
Shift operations

An expression of unsigned type is the subject of a left shift operation and examination of the context suggests that high order bits will sometimes be lost. Is this intended ?

For example:


/*PRQA S 2017,2983,2986,3120,3199,3381,3408 ++*/
/*******************************/
/* OPTIONS: -s int=16          */
/*******************************/
void foo(unsigned int un)
{
    if (un > 0x1000U)
    {
    }

    un = un << 4;                     /* 2922 */
}

See also:

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