[previous] 2790 [next] Constant: Right hand operand of shift operator is negative or too large.
Shift operations

The right hand operand of this shift operation is a constant expression with a value which is not permitted. The value must be less than the number of bits in the type of the left hand operand and must not be negative.

For example, if the type of the left hand operand is unsigned long, and long is implemented in 32 bits, the value of the right hand operand must not be less than 0 or greater than 31.

Notice that objects of small integer type will undergo integral promotion before being shifted. It may therefore be possible to shift objects of such types by an amount greater than their original width but the value resulting from such an operation may depend on the implemented size of type int.


/*PRQA S 2017,3120,3408,3447 ++*/

extern unsigned long ula;

extern void foo(void)
{
    ula = ula << -2;                  /* 2790      */
    ula = ula << 40;                  /* 2790 2921 */
}

See also:

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