Examples of errors detected by the V674 diagnostic.


V674. The expression contains a suspicious mix of integer and real types.


Geant4 software

V674 The '1.1' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'std::abs(ZBalance) > 1.1' expression. G4hadronic_deex_multifragmentation g4statmfmicropartition.cc 351


G4StatMFChannel * G4StatMFMicroPartition::ChooseZ(
  const G4double A0, const G4double Z0, const G4double MeanT)
// Gives fragments charges
{
  ....
  G4int ZBalance = 0;
  ....
  while (std::abs(ZBalance) > 1.1);
}

Similar errors can be found in some other places:

  • V674 The '1.5' literal of the 'double' type is compared to a value of the 'int' type. G4hadronic_mgt g4hadronicprocess.cc 222
  • V674 The '2.5' literal of the 'double' type is compared to a value of the 'int' type. G4hadronic_qmd g4tripathicrosssection.hh 59
  • V674 The '.99' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'tZ < .99' expression. G4hadronic_crosec_ci g4qantibaryonplusnuclearcrosssection.cc 343
  • And 11 additional diagnostic messages.

Source Engine SDK

V674 The '0.00001' literal of the 'double' type is subtracted from a variable of the 'int' type. Consider inspecting the 'speedCopy -= 0.00001' expression. Client (HL2) c_te_bloodstream.cpp 141


void TE_BloodStream(....)
{
  ....
  int      speedCopy = amount;
  ....
  speedCopy -= 0.00001;// so last few will drip
  ....
}

Source Engine SDK

V674 The '-0.1' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'step > - 0.1' expression. Client (HL2) prediction.cpp 977


#define  ON_EPSILON    0.1

void CPrediction::SetIdealPitch (....)
{
  int    step;
  ....
  step = floor_height[j] - floor_height[j-1];
  if (step > -ON_EPSILON && step < ON_EPSILON)
    continue;
  ....
}

Similar errors can be found in some other places:

  • V674 The '0.1' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'step < 0.1' expression. Client (HL2) prediction.cpp 977
  • V674 The '0.1' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'step - dir > 0.1' expression. Client (HL2) prediction.cpp 980
  • V674 The '-0.1' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'step - dir < - 0.1' expression. Client (HL2) prediction.cpp 980
  • And 7 additional diagnostic messages.

FlightGear

V674 The '0.01' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'range < 0.01' expression. navdb.cxx 172


static PositionedID readNavFromStream(....)
{
  ....
  int freq, range;
  ....
  if (range < 0.01) {
    range = defaultNavRange(ident, type);
  }
  ....
}

LibreOffice

V674 The '0.001' literal of the 'double' type is compared to a value of the 'long' type. Consider inspecting the 'pIndent->GetMRest() > 0.001' expression. lwpbulletstylemgr.cxx 177


sal_Int32 GetMRest() const {return m_nRest;}

OUString LwpBulletStyleMgr::RegisterBulletStyle(....)
{
  ....
  if (pIndent->GetMRest() > 0.001)
  ....
}

Godot Engine

V674 The '0.5' literal of the 'double' type is compared to a value of the 'int' type. tween.cpp 272


real_t _run_equation(...);

Variant Tween::_run_equation(InterpolateData& p_data)
{
  ....
  Variant result;
  ....
  switch(initial_val.get_type())
  {
  case Variant::BOOL:
    result = ((int) _run_equation(....)) >= 0.5;
    break;
  ....
  }
  ....
}

Unreal Engine 4

V674 The '0.01f' literal of the 'float' type is compared to a value of the 'unsigned char' type. Consider inspecting the 'SoftVert->InfluenceWeights[j] > 0.01f' expression. skeletalmeshtools.cpp 495


uint8 InfluenceWeights[MAX_TOTAL_INFLUENCES];

void CalcBoneVertInfos(....)
{
  ....
  if(SoftVert->InfluenceWeights[j] > 0.01f)
  {
    ....
  }
  ....
}

Open X-Ray Engine

V674 The '0.5f' literal of the 'float' type is compared to a value of the 'int' type. boneprotections.cpp 54


void SBoneProtections::reload(const shared_str& bone_sect,
                              IKinematics* kinematics)
{
  ....
  CInifile::Sect &protections = pSettings->r_section(bone_sect);
  for (CInifile::SectCIt i=protections.Data.begin();
       protections.Data.end() != i; ++i)
  {
    string256 buffer;
    BoneProtection BP;
    ....
    BP.BonePassBullet = (BOOL) (
                atoi(_GetItem(i->second.c_str(), 2, buffer))
                                                       > 0.5f);
    ....
  }
}

ICQ

V674 The '0.0001f' literal of the 'float' type is compared to a value of the 'int' type. Consider inspecting the '_actual_vol <= 0.0001f' expression. gui videopanel.cpp 190


....
int _actual_vol;
....
void Ui::VolumeControl::_updateSlider()
{
  ....
  if (_audioPlaybackDeviceMuted || _actual_vol <= 0.0001f) {
  ....
}

Similar errors can be found in some other places:

  • V674 The '0.0001f' literal of the 'float' type is compared to a value of the 'int' type. Consider inspecting the '_actual_vol <= 0.0001f' expression. gui videopanel.cpp 196
  • V674 The '0.0001f' literal of the 'float' type is compared to a value of the 'int' type. Consider inspecting the '_actual_vol <= 0.0001f' expression. gui videopanel.cpp 224
  • V674 The '0.0001f' literal of the 'float' type is compared to a value of the 'int' type. Consider inspecting the '_actual_vol <= 0.0001f' expression. gui videopanel.cpp 226
  • And 2 additional diagnostic messages.

CMaNGOS

V674 The '0.1f' literal of the 'float' type is compared to a value of the 'unsigned int' type. item_scripts.cpp 44


uint32 GetHealth()    const { return GetUInt32Value(...); }
uint32 GetMaxHealth() const { return GetUInt32Value(...); } // <=

bool ItemUse_item_orb_of_draconic_energy(....)
{
  ....
  if (pEmberstrife && pEmberstrife->HasAura(SPELL_DOMINION_SOUL)
      || pEmberstrife->GetHealth() /
         pEmberstrife->GetMaxHealth() > 0.1f)               // <=
  {
    ....
    return true;
  }
  return false;
}

Tizen

V674 The '0.5' literal of the 'double' type is assigned to a variable of the 'int' type. Consider inspecting the '= 0.5' expression. add-viewer.c 824


static void preview_down_cb(....)
{
  ....
  int delay = 0.5;                            // <=
  double fdelay;
  fdelay = ((double)delay / 1000.0f);
  DbgPrint("Long press: %lf\n", fdelay);
  ....
}

The default value was 500 milliseconds. Correct variant: int delay = 500;


EFL Core Libraries

V674 The '0.001' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'abs(st->info.mx) > 0.001' expression. elm_gesture_layer.c 2533

V674 The '0.001' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'abs(st->info.my) > 0.001' expression. elm_gesture_layer.c 2534


extern int abs (int __x) __attribute__ ((__nothrow__ , __leaf__))
                         __attribute__ ((__const__)) ;

#define ELM_GESTURE_MINIMUM_MOMENTUM 0.001

typedef int Evas_Coord;

struct _Elm_Gesture_Momentum_Info
{
  ....
  Evas_Coord mx;
  Evas_Coord my;
  ....
};

static void
_momentum_test(....)
{
  ....
  if ((abs(st->info.mx) > ELM_GESTURE_MINIMUM_MOMENTUM) ||
      (abs(st->info.my) > ELM_GESTURE_MINIMUM_MOMENTUM))
    state_to_report = ELM_GESTURE_STATE_END;
  ....
}

MuseScore

V674 The '-2.5' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'alter < - 2.5' expression. importmxmlpass2.cpp 5253


void MusicXMLParserPass2::pitch(int& step, int& alter ....)
{
  ....
  alter = MxmlSupport::stringToInt(strAlter, &ok;);
  if (!ok || alter < -2.5 || alter > 2.5) {
    logError(QString("invalid alter '%1'").arg(strAlter));
    ....
    alter = 0;
  }
  ....
}

Rosegarden

V674 The '0.1' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'm_connectingLineLength > 0.1' expression. StaffLayout.cpp 1028


class StaffLayout
{
  ....
protected:
  int m_connectingLineLength;
  ....
}

int m_connectingLineLength;

void
StaffLayout::resizeStaffLineRow(int row, double x, double length)
{
  ....
  if (m_pageMode != LinearMode && m_connectingLineLength > 0.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;
On our website we use a cookie to collect information of a technical nature.
If you do not agree, please leave the site. Learn More →
Do not show again