[previous] 2860 [next] Constant: Implementation-defined value resulting from left shift operation on expression of signed type.
Shift operations

The value of a constant expression of signed type is being shifted left.

The resulting value will be implementation-defined because, either
  1. The value of the left hand operand is negative, or
  2. The value of the left hand operand is positive and the shifted value cannot be represented in the signed type.

Left shift operations on signed data are not usually meaningful unless the value is non-negative before the shift and remains a representable, non-negative value after the shift.

For example:


/*PRQA S 271,1277,1279,2017,2982,2983,2984,2986,3120,3198,3199,3203,3408 ++*/

#define LVAL 0x1FFFFFFFL

extern void foo(void)
{
    long sl;

    sl = LVAL << 1;      /*      */
    sl = LVAL << 2;      /*      */
    sl = LVAL << 3;      /* 2860 */
    sl = LVAL << 4;      /* 2860 */
}

See also:

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