[previous] 2921 [next] Definite: 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 indicates that high order bits will always be lost. Is this intended ?

For example:


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

See also:

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