C5921: Shift count out of range

[WARNING]

Description

The compiler has detected that there is a shift count exceeding the object size of the object to be shifted. This is normally not a problem, but can be optimized by the compiler. For right shifts (>>), the compiler will replace the shift count with (sizeOfObjectInBits-1), that is a shift of a 16bit object (e.g. a short value) with a right shift by twenty is replaced with a right shift by 15. This message may be generated during tree optimizations (Option -Ont to switch it off).

Example
  unsigned char uch, res;

  
  res = uch >> 9;  // uch only has 8 bits, warning here

  
                   // will be optimized to 'res = uch>>7'

  

See also