To get a trial key
fill out the form below
Team License (standard version)
Enterprise License (extended version)
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
GBP
RUB
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
Examples of errors detected by the V674…

Examples of errors detected by the V674 diagnostic

April 5, 2021

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


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;
  ....
}

Similar errors can be found in some other places:

  • 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

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) {
  ....
}

0 A.D.

V674 CWE-682 The '0.5' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'bIsOrientationPreserving > 0.5' expression. MikktspaceWrap.cpp 137


typedef int tbool;

void MikkTSpace::setTSpace(....,
                           const tbool bIsOrientationPreserving,
                           ....)
{
  ....
  m_NewVertices.push_back(bIsOrientationPreserving > 0.5 ? 1.0f : (-1.0f));
  ....
}

Stellarium

V674 The literal '0.4' of 'double' type is being implicitly cast to 'int' type while calling the 'QColor' function. Inspect the first argument. SatellitesDialog.cpp 413


QColor(int r, int g, int b, int a = 255);

void SatellitesDialog::updateSatelliteData()
{
  ....
  // set default
  buttonColor = QColor(0.4, 0.4, 0.4);
  ....
}

Popular related articles
The Last Line Effect

Date: 05.31.2014

Author: Andrey Karpov

I have studied many errors caused by the use of the Copy-Paste method, and can assure you that programmers most often tend to make mistakes in the last fragment of a homogeneous code block. I have ne…
PVS-Studio for Java

Date: 01.17.2019

Author: Andrey Karpov

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've co…
Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives

Date: 07.31.2017

Author: Andrey Karpov

After I wrote quite a big article about the analysis of the Tizen OS code, I received a large number of questions concerning the percentage of false positives and the density of errors (how many erro…
The Evil within the Comparison Functions

Date: 05.19.2017

Author: Andrey Karpov

Perhaps, readers remember my article titled "Last line effect". It describes a pattern I've once noticed: in most cases programmers make an error in the last line of similar text blocks. Now I want t…
How PVS-Studio Proved to Be More Attentive Than Three and a Half Programmers

Date: 10.22.2018

Author: Andrey Karpov

Just like other static analyzers, PVS-Studio often produces false positives. What you are about to read is a short story where I'll tell you how PVS-Studio proved, just one more time, to be more atte…
Appreciate Static Code Analysis!

Date: 10.16.2017

Author: Andrey Karpov

I am really astonished by the capabilities of static code analysis even though I am one of the developers of PVS-Studio analyzer myself. The tool surprised me the other day as it turned out to be sma…
The Ultimate Question of Programming, Refactoring, and Everything

Date: 04.14.2016

Author: Andrey Karpov

Yes, you've guessed correctly - the answer is "42". In this article you will find 42 recommendations about coding in C++ that can help a programmer avoid a lot of errors, save time and effort. The au…
Technologies used in the PVS-Studio code analyzer for finding bugs and potential vulnerabilities

Date: 11.21.2018

Author: Andrey Karpov

A brief description of technologies used in the PVS-Studio tool, which let us effectively detect a large number of error patterns and potential vulnerabilities. The article describes the implementati…
The way static analyzers fight against false positives, and why they do it

Date: 03.20.2017

Author: Andrey Karpov

In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of synthetic tests. In that article, I give the example of a code fragment…
Free PVS-Studio for those who develops open source projects

Date: 12.22.2018

Author: Andrey Karpov

On the New 2019 year's eve, a PVS-Studio team decided to make a nice gift for all contributors of open-source projects hosted on GitHub, GitLab or Bitbucket. They are given free usage of PVS-Studio s…

Comments (0)

Next comments

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →
Accept