Examples of errors detected by the V610 diagnostic.


V610. Undefined behavior. Check the shift operator.


lib7z

V610 Undefined behavior. Check the shift operator '<<'. The right operand ('(8 * i)' = [0..56]) is greater than or equal to the length in bits of the promoted left operand. lib7z 7zin.c 233


SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream,
                               UInt64 *value)
{
  int i;
  *value = 0;
  for (i = 0; i < 8; i++)
  {
    Byte b;
    RINOK(SafeReadDirectByte(inStream, &b;));
    *value |= ((UInt32)b << (8 * i));
  }
  return SZ_OK;
}

Game_Music_Emu library

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0x2F00' is negative. game-music-emu spc_cpu.cpp 437


void Snes_Spc::cpu_write(....)
{
  ...
  if ( ((~0x2F00 << (bits_in_int - 16)) << reg) < 0 ) // 36%
  ...
}

FAAC

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. libfaac bitstream1.c 796


static int WriteTNSData(....)
{
  ...
  unsignedIndex = (unsigned long) (
    tnsFilterPtr->index[i])&(~(~0<<bitsToTransmit));
  ...
}

Blender

V610 Unspecified behavior. Check the shift operator '>>'. The left operand '(- 1)' is negative. bf_editor_space_view3d view3d_draw.c 101


#define cpack(x) glColor3ub( ((x)&0xFF), (((x)>>8)&0xFF), \
(((x)>>16)&0xFF) )

static void star_stuff_init_func(void)
{
  cpack(-1);
  glPointSize(1.0);
  glBegin(GL_POINTS);
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. bf_intern_ghost ghost_ndofmanager.cpp 289
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '(~0)' is negative. extern_bullet btquantizedbvh.h 82
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '(~0)' is negative. extern_bullet btsoftbodyconcavecollisionalgorithm.h 48

UCSniff

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~1' is negative. ec_ip.c 187


#define FP_HOST_NONLOCAL   1<<1

FUNC_DECODER(decode_ip)
{
  ...
  PACKET->PASSIVE.flags &= ~FP_HOST_NONLOCAL;
  ...
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~1' is negative. ec_ip6.c 110

DeSmuME

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. DeSmuME_VS2005 mmu_timing.h 158


enum { TAGMASK = (u32)(~0 << TAGSHIFT) };

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. DeSmuME_VS2005 cheatsystem.cpp 1335
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 1)' is negative. DeSmuME_VS2005 gfx3d.cpp 811
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '(SBits) - 8' is negative. DeSmuME_VS2005 lua-engine.cpp 1345
  • And 2 additional diagnostic messages.

MAME

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. atarig42.c 220

V610 Undefined behavior. Check the shift operator '<<'. The right operand ('i' = [0..43]) is greater than or equal to the length in bits of the promoted left operand. firetrk.c 113


#define ATARIRLE_PRIORITY_SHIFT  12
#define ATARIRLE_PRIORITY_MASK \
  ((~0 << ATARIRLE_PRIORITY_SHIFT) & 0xffff)

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. atarigx2.c 214
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. atarisy1.c 524
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. atarisy2.c 354
  • And 46 additional diagnostic messages.

MAME

V610 Undefined behavior. Check the shift operator '<<'. The right operand ('i' = [0..43]) is greater than or equal to the length in bits of the promoted left operand. firetrk.c 111


UINT32 m_color1_mask;
UINT32 m_color2_mask;

#define ARRAY_LENGTH(x) (sizeof(x) / sizeof(x[0]))

PALETTE_INIT( montecar )
{
 static const UINT8 colortable_source[] =
 {
  0x00, 0x00, 0x00, 0x01,
  0x00, 0x02, 0x00, 0x03,
  0x03, 0x03, 0x03, 0x02,
  0x03, 0x01, 0x03, 0x00,
  0x00, 0x00, 0x02, 0x00,
  0x02, 0x01, 0x02, 0x02,
  0x00, 0x10, 0x20, 0x30,
  0x00, 0x04, 0x08, 0x0c,
  0x00, 0x44, 0x48, 0x4c,
  0x00, 0x84, 0x88, 0x8c,
  0x00, 0xc4, 0xc8, 0xcc
 };
  ...
 for (i = 0; i < ARRAY_LENGTH(colortable_source); i++)
 {
  UINT8 color = colortable_source[i];

  if (color == 1)
   state->m_color1_mask |= 1 << i;                  // <=
  else if (color == 2)
   state->m_color2_mask |= 1 << i;                  // <=

  prom_to_palette(machine, i,
    color_prom[0x100 + colortable_source[i]]);
 }
  ...
}

Clang

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0L' is negative. bitvector.h 175


int find_next(unsigned Prev) const {
  ...
  // Mask off previous bits.
  Copy &= ~0L << BitPos;
  ...
}

Clang

V610 Undefined behavior. Check the shift operator '<<=. The left operand 'Val' is negative. pointerintpair.h 139


static Ty getEmptyKey() {
  intptr_t Val = -1;
  Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
  return Ty(reinterpret_cast<PointerTy>(Val),
            IntType((1 << IntBits)-1));
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0L' is negative. bitvector.h 454
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0L' is negative. sparsebitvector.h 161
  • V610 Undefined behavior. Check the shift operator '<<=. The left operand 'Val' is negative. pointerintpair.h 144
  • And 2 additional diagnostic messages.

Samba

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. idtree.c 284


static void *_idr_find(struct idr_context *idp, int id)
{
  ....
  if (n + IDR_BITS < 31 &&
      ((id & ~(~0 << MAX_ID_SHIFT)) >> (n + IDR_BITS))) {
    return NULL;
  }
  ....
}

OpenCV

V610 Unspecified behavior. Check the shift operator '>>'. The left operand '(- 2147483647 - 1)' is negative. contours.cpp 1012


CvSeq * cvFindNextContour( CvContourScanner scanner )
{
  ....
  new_mask = INT_MIN >> 1;
  ....
}

ReactOS

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-16' is negative. vl_mpeg12_bitstream.c 653


static INLINE int
wrap(short f, int shift)
{
  ....
  if (f < (-16 << shift))
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 1)' is negative. jdarith.c 460
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 1)' is negative. jdhuff.c 930
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 1)' is negative. layer1.c 86
  • And 6 additional diagnostic messages.

Skia Graphics Engine

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-2' is negative. skfixed.h 88


inline SkFract SkFixedToFract(SkFixed x)
{
  SkASSERT(x >= (-2 << 16) && x <= (2 << 16) - 1);
  return x << 14;
}

WebP

V610 Unspecified behavior. Check the shift operator '>>'. The left operand is negative ('(89858 * (i - 128) + YUV_HALF)' = [-11469056..11444734]). yuv.c 40

V610 Unspecified behavior. Check the shift operator '>>'. The left operand is negative ('(113618 * (i - 128) + YUV_HALF)' = [-14510336..14462254]). yuv.c 43


void VP8YUVInit(void) {
  ....
  for (i = 0; i < 256; ++i) {
    VP8kVToR[i] = (89858 * (i - 128) + YUV_HALF) >> YUV_FIX;
    VP8kUToG[i] = -22014 * (i - 128) + YUV_HALF;
    VP8kVToG[i] = -45773 * (i - 128);
    VP8kUToB[i] = (113618 * (i - 128) + YUV_HALF) >> YUV_FIX;
  }
  ....
}

Similar errors can be found in some other places:

  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand is negative ('((i - 16) * 76283 + YUV_HALF)' = [-18504001..35504363]). yuv.c 46

Chromium

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. webm_cluster_parser.cc 217


bool WebMClusterParser::ParseBlock(....)
{
  int timecode = buf[1] << 8 | buf[2];
  ....
  if (timecode & 0x8000)
    timecode |= (-1 << 16);
  ....
}

Mesa 3D Graphics Library

V610 Undefined behavior. Check the shift operator '<<'. The right operand ('i' = [0..47]) is greater than or equal to the length in bits of the promoted left operand. s_span.c 768


#define MAX_VARYING 32

typedef enum
{
  ....
  FRAG_ATTRIB_VAR0 = 16,
  FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING)
} gl_frag_attrib;

static inline GLuint
clip_span( struct gl_context *ctx, SWspan *span )
{
  ....
  for (i = 0; i < FRAG_ATTRIB_MAX; i++) {
    if (span->interpMask & (1 << i)) {
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The right operand ('i' = [0..47]) is greater than or equal to the length in bits of the promoted left operand. s_span.c 789

WebRTC

V610 Undefined behavior. Check the shift operator '<<'. The right operand ('i' = [0..63]) is greater than or equal to the length in bits of the promoted left operand. rtcp_sender.cc 1105


int32_t
RTCPSender::BuildREMB(uint8_t* rtcpbuffer, uint32_t& pos)
{
  ....
  for(uint32_t i=0; i<64; i++)
  {
    if(_rembBitrate <= ((uint32_t)262143 << i))
    {
      brExp = i;
      break;
    }
  }
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The right operand ('i' = [0..63]) is greater than or equal to the length in bits of the promoted left operand. rtcp_sender.cc 1222
  • V610 Undefined behavior. Check the shift operator '<<'. The right operand ('i' = [0..63]) is greater than or equal to the length in bits of the promoted left operand. rtcp_sender.cc 1288

Skia Graphics Engine

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. skedge.cpp 414


int SkCubicEdge::setCubic(const SkPoint pts[4],
                          const SkIRect* clip, int shift)
{
  ....
  fCurveCount = SkToS8(-1 << shift);
  ....
}

Skia Graphics Engine

V610 Unspecified behavior. Check the shift operator '>>'. The left operand '-0xFFFF' is negative. skradialgradient.cpp 82


void shadeSpan16_radial_clamp(....) {
  ....
  fy = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1);
  ....
}

Similar errors can be found in some other places:

  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '-0xFFFF' is negative. skradialgradient.cpp 85
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '-0xFFFF' is negative. skradialgradient.cpp 95
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '-0xFFFF' is negative. skradialgradient.cpp 96
  • And 4 additional diagnostic messages.

usrsctp

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. sctp_output.c 10898


void
sctp_send_sack(struct sctp_tcb *stcb, int so_locked)
{
  ....
  tsn_map &= (~0 << (1 - offset));
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. sctp_output.c 10972
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0L' is negative. bitvect.c 404
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0L' is negative. bitvect.c 759
  • And 14 additional diagnostic messages.

Snes9x

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. sar.h 217


static inline int64 SAR (const int64 b, const int n)
{
#ifndef RIGHTSHIFT_int64_IS_SAR
  if (b < 0)
    return ((b >> n) | (-1 << (64 - n)));
#endif
  return (b >> n);
}

Similar errors can be found in some other places:

  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '(SBits) - 8' is negative. lua-engine.cpp 1296
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '(SBits) - 8' is negative. lua-engine.cpp 1306
  • V610 Undefined behavior. Check the shift operator '<<'. The right operand is negative ('x2' = [-1..3]). lua-engine.cpp 3284

Snes9x

V610 Unspecified behavior. Check the shift operator '>>=. The left operand 'C' is negative. dsp1.cpp 808


static void DSP1_Parameter (....)
{
  int16  C;
  ....
  if (C == -32768)
  {
    C >>= 1;
    E++;
  }
  ....
}

VirtualDub

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. VirtualDub avioutputgif.cpp 702


void AVIVideoGIFOutputStream::write(....) {
{
  ....
  for(int i=0; i<palsize; ++i)
    dict[i].mPrevAndLastChar = (-1 << 16) + i;
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-0x0100' is negative. VirtualDub audiosource.cpp 602
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-0x0200' is negative. VirtualDub audiosource.cpp 603
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-0x0300' is negative. VirtualDub audiosource.cpp 604
  • And 16 additional diagnostic messages.

speex

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 1)' is negative. bits.c 278


EXPORT int speex_bits_unpack_signed(SpeexBits *bits,
                                    int nbBits)
{
   unsigned int d=speex_bits_unpack_unsigned(bits,nbBits);
   /* If number is negative */
   if (d>>(nbBits-1))
   {
      d |= (-1)<<nbBits;
   }
   return d;
}

PostgreSQL Database Management System

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. postgres inet_cidr_ntop.c 206


static char *
inet_cidr_ntop_ipv6(const u_char *src, int bits,
                    char *dst, size_t size)
{
  ....
  m = ~0 << (8 - b);
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '((int64) - 1)' is negative. postgres network.c 1435
  • V610 Undefined behavior. Check the shift operator '<<'. The right operand is negative ('((i) - 1)' = [-1..30]). postgres signal.c 118
  • V610 Undefined behavior. Check the shift operator '<<'. The right operand is negative ('((i) - 1)' = [-1..30]). postgres signal.c 125
  • And 2 additional diagnostic messages.

Source Engine SDK

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0x03' is negative. Client (HL2) c_func_breakablesurf.cpp 157


inline void SetStyleType( int w, int h, int type )
{
  Assert( type < NUM_EDGE_STYLES );
  Assert( type >= 0 );
  // Clear old value
  m_nPanelBits[ w ][ h ] &= ( ~0x03 << 2 );
  // Insert new value
  m_nPanelBits[ w ][ h ] |= ( type << 2 );
}

LibRaw

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. dcraw_common.cpp 1827


unsigned CLASS pana_bits (int nbits)
{
  ....
  return (buf[byte] | buf[byte+1] << 8) >>
         (vbits & 7) & ~(-1 << nbits);
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. dcraw_common.cpp 1851
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. dcraw_common.cpp 2085
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. dcraw_common.cpp 2814
  • And 1 additional diagnostic messages.

GNU C Library

V610 Unspecified behavior. Check the shift operator '>>'. The left operand '~0xff' is negative. strxfrm_l.c 68


utf8_encode (char *buf, int val)
{
  ....
  *buf = (unsigned char) (~0xff >> step);
  ....
}

Similar errors can be found in some other places:

  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '~0xff' is negative. loop.c 331
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '~0xff' is negative. loop.c 437
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '-1' is negative. mktime.c 207
  • And 19 additional diagnostic messages.

GNU C Library

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. cacheinfo.c 645


static void init_cacheinfo (void)
{
  ....
  count_mask = ~(-1 << (count_mask + 1));
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~(clockid_t)(0)' is negative. clock_nanosleep.c 38
  • V610 Undefined behavior. Check the shift operator '<<=. The left operand 'c' is negative. ifaddrs.c 786
  • V610 Undefined behavior. Check the shift operator '>>'. The right operand '32' is greater than or equal to the length in bits of the promoted left operand. xdr_intXX_t.c 35
  • And 8 additional diagnostic messages.

Firebird

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(~0)' is negative. ods.h 337


const ULONG END_BUCKET = (~0) << 1;

Similar errors can be found in some other places:

  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand is negative ('i64value' = [-2147483648..2147483647]). exprnodes.cpp 6185
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand is negative ('literal' = [-32768..32767]). array.cpp 845

V8 JavaScript Engine

V610 Undefined behavior. Check the shift operator '>>'. The right operand 'shift_bits' is greater than or equal to the length in bits of the promoted left operand. v8.h 5343


template <> struct SmiTagging<8> {

  static const int kSmiShiftSize = 31;
  static const int kSmiValueSize = 32;

  V8_INLINE static int SmiToInt(internal::Object* value) {
    int shift_bits = kSmiTagSize + kSmiShiftSize;
    return static_cast<int>(reinterpret_cast<intptr_t>(value) >>
      shift_bits);
  }
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. objects.h 6433
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~kMaxCachedArrayIndexLength' is negative. objects.h 8624
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '-8' is negative. test-utils.cc 55
  • And 4 additional diagnostic messages.

FlightGear

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0x01' is negative. standardmanipulator 185


inline void StandardManipulator::setRelativeFlag(
  int index, bool value )
{
  if( value )  _relativeFlags |= (0x01 << index);
  else  _relativeFlags &= (~0x01 << index);
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 1)' is negative. bits.c 266
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-2560' is negative. short_term.c 68
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1792' is negative. short_term.c 71
  • And 5 additional diagnostic messages.

FFmpeg

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. diracdec.c 1358


static int mc_subpel(....)
{
  ....
  mx = motion_x & ~(-1 << s->mv_precision);
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. apedec.c 1297
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. diracdec.c 1359
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. g723_1.c 2145
  • And 49 additional diagnostic messages.

Tesseract

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. libtesseract303 dawg.cpp 187


void Dawg::init(....)
{
  ....
  letter_mask_ = ~(~0 << flag_start_bit_);
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. libtesseract303 dawg.cpp 188
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. libtesseract303 intmatcher.cpp 172
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. libtesseract303 intmatcher.cpp 174
  • And 17 additional diagnostic messages.

Newton Game Dynamics

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 1LL)' is negative. dggoogol.cpp 249


dgGoogol dgGoogol::Floor () const
{
  ....
  dgUnsigned64 mask = (-1LL) << (64 - bits);
  ....
}

Most likely this is what should be written here: dgUnsigned64 mask = (~0LLU) << (64 - bits);


Wine Is Not an Emulator

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(LONGLONG) - 1' is negative. propvar.c 127


static HRESULT PROPVAR_ConvertNumber(....)
{
  ....
  if (*res >= ((LONGLONG)1 << (dest_bits-1)) ||
      *res < ((LONGLONG)-1 << (dest_bits-1)))
    return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
  ....
}

Grassroots DICOM library (GDCM)

V610 Unspecified behavior. Check the shift operator '>>'. The left operand 'nmask' is negative. gdcmimagecodec.cxx 397


bool ImageCodec::DoOverlayCleanup(....)
{
  ....
  // nmask : to propagate sign bit on negative values
  int16_t nmask = (int16_t)0x8000;
  nmask = nmask >>
          ( PF.GetBitsAllocated() - PF.GetBitsStored() - 1 );
  ....
}

HDF5

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. h5znbit.c 974


static void
H5Z_nbit_decompress_one_byte(....)
{
  data[data_offset + k] =
    ((val >> (*buf_len - dat_len)) & ~(~0 << dat_len)) <<
      uchar_offset;
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. h5znbit.c 978
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. h5znbit.c 985
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. h5znbit.c 1003
  • And 12 additional diagnostic messages.

Miranda NG

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 1)' is negative. AdvaImg jdarith.c 460


METHODDEF(boolean)
decode_mcu_AC_refine (....)
{
  ....
  m1 = (-1) << cinfo->Al;
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 1)' is negative. AdvaImg jdhuff.c 930
  • V610 Undefined behavior. Check the shift operator '>>'. The right operand ('(8 * x)' = [0..56]) is greater than or equal to the length in bits of the promoted left operand. Libgcrypt cipher.c 1529

Spring Engine

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 1)' is negative. engine-dedicated%engine-headless%engine-legacy%unitsync cpuid.cpp 176


void CpuId::getMasksIntelLeaf11()
{
  getMasksIntelLeaf11Enumerate();

  // We determined the shifts now compute the masks
  maskVirtual = ~((-1) << shiftCore);
  maskCore = (~((-1) << shiftPackage)) ^ maskVirtual;
  maskPackage = (-1) << shiftPackage;
}

Linux Kernel

V610 Undefined behavior. Check the shift operator '<<. The left operand '-1' is negative. hid-core.c 1016


static s32 snto32(__u32 value, unsigned n)
{
  switch (n) {
  case 8:  return ((__s8)value);
  case 16: return ((__s16)value);
  case 32: return ((__s32)value);
  }
  return value & (1 << (n - 1)) ? value | (-1 << n) : value;
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '>>. The right operand ('(5 * i)' = [0..45]) is greater than or equal to the length in bits of the promoted left operand. ar9003_hw.c 1022
  • V610 Undefined behavior. Check the shift operator '<<. The left operand '~(1 << 1)' is negative. bnx2x_link.c 10910
  • V610 Undefined behavior. Check the shift operator '<<. The left operand '~0' is negative. tmscsim.c 1109
  • And 113 additional diagnostic messages.

LibreOffice

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(~int (0))' is negative. grammar.hxx 56


static const int kConventionShift = 16;
static const int kFlagMask = ~((~int(0)) << kConventionShift);

.NET CoreCLR

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. bcltype metamodel.h 532


inline static mdToken decodeToken(....)
{
    //<TODO>@FUTURE: make compile-time calculation</TODO>
    ULONG32 ix = (ULONG32)(val & ~(-1 << m_cb[cTokens]));

    if (ix >= cTokens)
        return rTokens[0];
    return TokenFromRid(val >> m_cb[cTokens], rTokens[ix]);
}

.NET CoreCLR

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(~0)' is negative. cee_dac decodemd.cpp 456


#define bits_generation 2
#define generation_mask (~(~0 << bits_generation))

#define MASK(len) (~((~0)<<len))
#define MASK64(len) ((~((~((unsigned __int64)0))<<len)))

void Encoder::Add(unsigned value, unsigned length)
{
  ....
  value = (value & MASK(length));
  ....
}

SETI@home

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. analyzefuncs.cpp 177


int seti_analyze (ANALYSIS_STATE& state)
{
  ....
  int last_chirp_ind = - 1 << 20, chirprateind;
  ....
}

Apple II emulator

V610 Unspecified behavior. Check the shift operator '>>'. The left operand 'SPKR_DATA_INIT' is negative. speaker.cpp 450


const short SPKR_DATA_INIT = (short)0x8000;

BYTE __stdcall SpkrToggle (....)
{
  ....
  if (g_nSpeakerData == (SPKR_DATA_INIT >> 2))
  ....
}

Similar errors can be found in some other places:

  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand 'SPKR_DATA_INIT' is negative. speaker.cpp 453
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '~0x180' is negative. tfe.cpp 869
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '~0x100' is negative. tfe.cpp 987

Mozilla Thunderbird

V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0L' is negative. nsprotocolproxyservice.cpp 336


static void
proxy_MaskIPv6Addr(PRIPv6Addr &addr, uint16_t mask_len)
{
  ....
  addr.pr_s6_addr32[3] = PR_htonl(
    PR_ntohl(addr.pr_s6_addr32[3]) & (~0L << (128 - mask_len)));
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0L' is negative. nsprotocolproxyservice.cpp 341
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0L' is negative. nsprotocolproxyservice.cpp 347
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0L' is negative. nsprotocolproxyservice.cpp 354

OpenMW

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 127 - 1)' is negative. globalmap.cpp 176


void GlobalMap::render (Loading::Listener* loadingListener)
{
  ....
  y = (SCHAR_MIN << 4) / 2048.f;
  ....
}

ChakraCore

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. constants.h 39


class Constants
{
public:
  ....
  static const int Int31MinValue = -1 << 30;
  ....
};

Oracle VM Virtual Box

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 2)' is negative. translate.c 2708


static void gen_push_T1(DisasContext *s)
{
  ....
  if (s->ss32 && !s->addseg)
    gen_op_mov_reg_A0(1, R_ESP);
  else
    gen_stack_update(s, (-2) << s->dflag);
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand is negative ('i64' = [-1..0]). tarvfs.cpp 234
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-16' is negative. translate.c 2761

Serious Engine 1 v.1.10

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(- 2)' is negative. layermaker.cpp 363


void CLayerMaker::SpreadShadowMaskOutwards(void)
{
  #define ADDNEIGHBOUR(du, dv)                                  \
  if ((pixLayerU+(du)>=0)                                       \
    &&(pixLayerU+(du)<pixLayerSizeU)                            \
    &&(pixLayerV+(dv)>=0)                                       \
    &&(pixLayerV+(dv)<pixLayerSizeV)                            \
    &&(pubPolygonMask[slOffsetMap+(du)+((dv)<<pixSizeULog2)])) {\
    ....                                                        \
    }

  ADDNEIGHBOUR(-2, -2); // <=
  ADDNEIGHBOUR(-1, -2); // <=
  ....                  // <=
}

Firebird

V610 Unspecified behavior. Check the shift operator '>>'. The left operand is negative ('literal' = [-32768..32767]). array.cpp 848


static ISC_STATUS stuff_literal(gen_t* gen, SLONG literal)
{
  ....
  if (literal >= -32768 && literal <= 32767)
    return stuff_args(gen, 3, isc_sdl_short_integer, literal,
                      literal >> 8);
  ....
}

Similar errors can be found in some other places:

  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand is negative ('i64value' = [-2147483648..2147483647]). exprnodes.cpp 6382

OpenSSL

V610 Undefined behavior. Check the shift operator '<<'. The left operand '(0xffffffffffffffffLL)' is negative. bn_lib.c 796


#define BN_MASK2 (0xffffffffffffffffLL)
int BN_mask_bits(BIGNUM *a, int n)
{
  ....
  a->d[w] &= ~(BN_MASK2 << b); //<=
  ....
}

CryEngine V

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. physicalplaceholder.h 25


#ifndef physicalplaceholder_h
#define physicalplaceholder_h
#pragma once
....
const int NO_GRID_REG = -1<<14;
const int GRID_REG_PENDING = NO_GRID_REG+1;
....

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~(TFragSeqStorage(0))' is negative. udpdatagramsocket.cpp 757
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. tetrlattice.cpp 324
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. tetrlattice.cpp 350
  • And 5 additional diagnostic messages.

Far2l

V610 Undefined behavior. Check the shift operator '<<'. The right operand 'sizeof (wchar_t) * 8' is greater than or equal to the length in bits of the promoted left operand. RegExp.cpp 4467


#define rechar wchar_t
#define RE_CHAR_COUNT (1 << sizeof(rechar) * 8)

int RegExp::Optimize()
{
  ....
  for (op=code; ; op=op->next)
  {
    switch (OP.op)
    {
    ....
    case opType:
    {
      for (int i = 0; i < RE_CHAR_COUNT; i++)    // <=
      {
        if (ISTYPE(i, OP.type))
        {
          first[i]=1;
        }
      }

      break;
    }
    }
    ....
  }
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The right operand 'sizeof (wchar_t) * 8' is greater than or equal to the length in bits of the promoted left operand. RegExp.cpp 4473
  • V610 Undefined behavior. Check the shift operator '<<'. The right operand 'sizeof (wchar_t) * 8' is greater than or equal to the length in bits of the promoted left operand. RegExp.cpp 4490
  • V610 Undefined behavior. Check the shift operator '<<'. The right operand 'sizeof (wchar_t) * 8' is greater than or equal to the length in bits of the promoted left operand. RegExp.cpp 4537
  • And 2 additional diagnostic messages.

FreeBSD Kernel

V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. pf_table.c 911


static void
pfr_prepare_network(union sockaddr_union *sa, int af, int net)
{
  ....
  sa->sin.sin_addr.s_addr = net ? htonl(-1 << (32-net)) : 0;
  ....
}

Similar errors can be found in some other places:

  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '-1' is negative. pf_table.c 918
  • V610 Unspecified behavior. Check the shift operator '>>'. The left operand '(0x1 << 31)' is negative. qls_dump.c 589
  • V610 Undefined behavior. Check the shift operator '<<'. The left operand '~0' is negative. bhnd_pmu_subr.c 790
  • And 22 additional diagnostic messages.

Valgrind

V610 Unspecified behavior. Check the shift operator '>>'. The left operand '((Long) 0x8000000000000000ULL)' is negative. guest_arm64_toIR.c 9428


static
Bool dis_AdvSIMD_scalar_shift_by_imm(DisResult* dres, UInt insn)
{
  ....
  ULong nmask = (ULong)(((Long)0x8000000000000000ULL) >> (sh-1));
  ....
}

EFL Core Libraries

V610 Unspecified behavior. Check the shift operator '>>'. The left operand '(- 0x7fffffff - 1)' is negative. ector_software_gradient.c 412


void fetch_linear_gradient(....)
{
  ....
  if (t + inc*length < (float)(INT_MAX >> (FIXPT_BITS + 1)) &&
      t+inc*length > (float)(INT_MIN >> (FIXPT_BITS + 1)))
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++ and C#

goto PVS-Studio;