Advertisement
PVS-StudioWarnings

PVS-Studio warning V610 for speex

Nov 21st, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. EXPORT int speex_bits_unpack_signed(SpeexBits *bits,
  2.                                     int nbBits)
  3. {
  4.    unsigned int d=speex_bits_unpack_unsigned(bits,nbBits);
  5.    /* If number is negative */
  6.    if (d>>(nbBits-1))
  7.    {
  8.       d |= (-1)<<nbBits;
  9.    }
  10.    return d;
  11. }
  12.  
  13. This suspicious code was found in speex project by PVS-Studio static code analyzer.
  14. Warning message is:
  15. V610 Undefined behavior. Check the shift operator '<<. The left operand '(- 1)' is negative. bits.c 278
  16.  
  17. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement