Examples of errors detected by the V634 diagnostic


V634. The priority of the '+' operation is higher than that of the '<<' operation. It's possible that parentheses should be used in the expression.


Haiku Operation System

V634 The priority of the '*' operation is higher than that of the '<<' operation. It's possible that parentheses should be used in the expression. RAW.cpp 1141


void
DCRaw::_WaveletDenoise()
{
  ....
  for (i = 0; i < (1 << dim * 2); i++) {  // <=
    if (fimg[i] < -fThreshold)
      fimg[i] += fThreshold;
    else if (fimg[i] > fThreshold)
      fimg[i] -= fThreshold;
    else
      fimg[i] = 0;
  }
  ....
}

Similar errors can be found in some other places:

  • V634 The priority of the '*' operation is higher than that of the '<<' operation. It's possible that parentheses should be used in the expression. RAW.cpp 1099

CryEngine V

V634 The priority of the '*' operation is higher than that of the '<<' operation. It's possible that parentheses should be used in the expression. model.cpp 336


enum joint_flags
{
  angle0_locked = 1,
  ....
};

bool CDefaultSkeleton::SetupPhysicalProxies(....)
{
  ....
  for (int j = 0; .... ; j++)
  {
    // lock axes with 0 limits range
    m_arrModelJoints[i]....flags |= (....) * angle0_locked << j;
  }
  ....
}

System Shock

V634 The priority of the '-' operation is higher than that of the '<<' operation. It's possible that parentheses should be used in the expression. FRCLIP.C 256


#define span_right(y,s) \
  (x_span_lists[((y)<<SPAN_SHIFT)+(s<<1)+SPAN_RIGHT])

void fr_span_parse(void)
  {
  ....
  if (....span_right(y,(*cur_span_cnt)-1)....)>frpipe_dist)
    ....
  ....
}

Stellarium

V634 The priority of the '*' operation is higher than that of the '<<' operation. It's possible that parentheses should be used in the expression. StelHips.cpp 271


HipsTile* HipsSurvey::getTile(int order, int pix)
{
  ....
  if (order == orderMin && !allsky.isNull())
  {
    int nbw = sqrt(12 * 1 << (2 * order));
    ....
  }
  ....
}

What the programmer must have really meant is this: int nbw = sqrt(12 * (1 << 2 * order));



Bugs Found

Checked Projects
334
Collected Errors
12 668