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 V601…

Examples of errors detected by the V601 diagnostic

April 5, 2021

V601. An odd implicit type casting.


IPP Samples

V601 The 'false' value becomes a class object. me umc_vec_prediction.cpp 754


class MeMV
{
public:
  MeMV(){};
  MeMV(int a0){x = (Ipp16s)a0; y=(Ipp16s)a0;};
  MeMV(int a0, int a1){x = (Ipp16s)a0; y=(Ipp16s)a1;};
  ....
}

MeMV MePredictCalculatorVC1::GetPrediction8x8()
{
  ....
  default:
    return false;
  ....
}

Similar errors can be found in some other places:

  • V601 The 'false' value becomes a class object. me umc_vec_prediction.cpp 717

WebPagetest

V601 The bool type is implicitly cast to the integer type. Inspect the first argument. web_browser.cc 548


HANDLE WebBrowser::FindAdditionalHookProcess(
  HANDLE launched_process, CString exe)
{
  ....
  CString exe(proc.szExeFile);
  exe.MakeLower();
  if (exe.Find(_T("webkit2webprocess.exe") >= 0)) {
  ....
}

This is what should have been written here: if (exe.Find(_T("webkit2webprocess.exe")) >= 0)


WebPagetest

V601 The bool type is implicitly cast to the integer type. Inspect the first argument. web_browser.cc 429


bool WebBrowser::FindBrowserChild(
  DWORD pid, PROCESS_INFORMATION& pi,
  LPCTSTR browser_exe)
{
  ....
  CString exe(proc.szExeFile);
  exe.MakeLower();
  if (exe.Find(browser_exe >= 0)) {
  ....
}

This is what should have been written here: if (exe.Find(browser_exe) >= 0)


Micro-Manager

V601 The 'false' value is implicitly cast to the integer type. Property.cpp 364


#define DEVICE_OK   0
#define DEVICE_ERR  1 // generic, undefined error
#define DEVICE_INVALID_PROPERTY  2

int MM::PropertyCollection::CreateProperty(....)
{
  if (Find(pszName))
    return DEVICE_DUPLICATE_PROPERTY;
  ....
  if (!pProp->Set(pszValue))
    return false;
  ....
  return DEVICE_OK;
}

Micro-Manager

V601 The 'true' value is implicitly cast to the integer type. Property.cpp 464


#define DEVICE_OK   0
#define DEVICE_ERR  1 // generic, undefined error
#define DEVICE_INVALID_PROPERTY  2

int MM::PropertyCollection::RegisterAction(
  const char* pszName, MM::ActionFunctor* fpAct)
{
  MM::Property* pProp = Find(pszName);
  if (!pProp)
    return DEVICE_INVALID_PROPERTY;
  pProp->RegisterAction(fpAct);
  return true;
}

Similar errors can be found in some other places:

  • V601 The 'false' value is implicitly cast to the integer type. PIGCSControllerCom.cpp 405
  • V601 The 'false' value is implicitly cast to the integer type. Prior.cpp 778
  • V601 The 'false' value is implicitly cast to the integer type. Prior.cpp 2308
  • And 8 additional diagnostic messages.

Doxygen

V601 The bool type is implicitly cast to the class type. Inspect the fifth argument. context.cpp 1712


static MemberListInfoContext *alloc(Definition *def,
                          const QCString &relPath,
                          const MemberList *ml,
                          const QCString &title,
                          const QCString &subtitle=QCString())
{ return new MemberListInfoContext(def,relPath,
                                     ml,title,subtitle); }

TemplateVariant getMemberList(
                         SharedPtr<MemberListInfoContext> &list,
                         MemberListType type,
                         const char *title,
                         bool detailed=FALSE) const
{
  ....
  MemberList *ml = m_classDef->getMemberList(type);
  ....
  list.reset(MemberListInfoContext::alloc(m_classDef,
                        relPathAsString(),ml,title,detailed));
  ....
}

Similar errors can be found in some other places:

  • V601 The bool type is implicitly cast to the class type. Inspect the fifth argument. context.cpp 2315
  • V601 The bool type is implicitly cast to the class type. Inspect the fifth argument. context.cpp 2675
  • V601 The bool type is implicitly cast to the class type. Inspect the fifth argument. context.cpp 4456

Doxygen

V601 The bool type is implicitly cast to the class type. docsets.cpp 473


struct IncludeInfo
{
  ....
  bool local;
};

void DocSets::addIndexItem(Definition *context,MemberDef *md,
                           const char *,const char *)
{
  QCString decl;
  ....
  IncludeInfo *ii = cd->includeInfo();
  ....
  decl=ii->local;
  ....
}

Firebird

V601 The string literal is implicitly cast to the bool type. Inspect the second argument. backup.cpp 6113


int put_message(....)
{
  if (newlen <= MAX_UCHAR)
  {
    put(tdgbl, attribute);
    put(tdgbl, (UCHAR) newlen);
  }
  else if (newlen <= MAX_USHORT)
  {
    if (!attribute2)
      BURP_error(314, "");
    ....
  }
  else
    BURP_error(315, "");
  ....
}

Similar errors can be found in some other places:

  • V601 The string literal is implicitly cast to the bool type. Inspect the second argument. backup.cpp 6120

Notepad++

V601 The 'false' value becomes a class object. treeview.cpp 121


typedef std::basic_string<TCHAR> generic_string;

generic_string TreeView::getItemDisplayName(....) const
{
  if (not Item2Set)
    return false;                     // <=
  TCHAR textBuffer[MAX_PATH];
  TVITEM tvItem;
  tvItem.hItem = Item2Set;
  tvItem.mask = TVIF_TEXT;
  tvItem.pszText = textBuffer;
  tvItem.cchTextMax = MAX_PATH;
  SendMessage(...., reinterpret_cast<LPARAM>(&tvItem));
  return tvItem.pszText;
}

SCIM

V601 The 'true' value is implicitly cast to the integer type. scim_anthy_style_file.cpp 204


static int get_value_position (String &str)           // <=
{
  ....
  if (spos >= str.length ())
    return true;                                      // <=
  else
    spos++;
  for (;
       spos < str.length () && isspace(str[spos]);
       spos++);

  return spos;
}

Rosegarden

V601 The integer type is implicitly cast to the char type. MidiEvent.cpp 181


QDebug &
operator<<(QDebug &dbg, const MidiEvent &midiEvent)
{
  timeT tempo;
  int tonality;
  std::string sharpflat;
  ....
  tonality = (int)midiEvent.m_metaMessage[0];

  if (tonality < 0) {
    sharpflat = -tonality + " flat"; // <=
  } else {
    sharpflat = tonality;            // <=
    sharpflat += " sharp";
  }
  ....
}

Rosegarden

V601 The string literal is implicitly cast to the bool type. FileSource.cpp 902


bool
FileSource::createCacheFile()
{
  {
    QMutexLocker locker(&m_mapMutex);

#ifdef DEBUG_FILE_SOURCE
    std::cerr << "...." << m_refCountMap[m_url] << std::endl;
#endif

    if (m_refCountMap[m_url] > 0) {
      m_refCountMap[m_url]++;
      m_localFilename = m_remoteLocalMap[m_url];
#ifdef DEBUG_FILE_SOURCE
      std::cerr << "...." << m_refCountMap[m_url] << std::endl;
#endif
      m_refCounted = true;
      return true;
    }
  }

  QDir dir;
  try {
      dir = TempDirectory::getInstance()->....;
  } catch (DirectoryCreationFailed f) {
#ifdef DEBUG_FILE_SOURCE
      std::cerr << "...." << f.what() << std::endl;
#endif
      return "";  // <=
  }
  ....
}

TON

V601 The 'false' value is implicitly cast to the integer type. mc-config.cpp 884


static int process_workchain_shard_hashes(....) {
  ....
  if (f == 1) {
    if ((shard.shard & 1) || cs.size_ext() != 0x20000) {
      return false;                                     // <=
    }
    ....
    int r = process_workchain_shard_hashes(....);
    if (r < 0) {
      return r;
    }
    ....
    return cb.store_bool_bool(true) && cb.store_ref_bool(std::move(left)) &&
            cb.store_ref_bool(std::move(right)) &&
            cb.finalize_to(branch)
               ? r
               : -1;
  ....
}

VVVVVV

V601 The integer type is implicitly cast to the char type. Game.cpp 4997


//Some stats:
int totalflips;
std::string hardestroom;
int hardestroomdeaths;

void Game::loadquick(....)
{
  ....

  else if (pKey == "totalflips")
  {
      totalflips = atoi(pText);
  }
  else if (pKey == "hardestroom")
  {
      hardestroom = atoi(pText);        // <=
  }
  else if (pKey == "hardestroomdeaths")
  {
      hardestroomdeaths = atoi(pText);
  }

  ....
}

Dlib

V601 The bool type is implicitly cast to the double type. console_progress_indicator.h 136


class console_progress_indicator
{
  ....
  double seen_first_val;
  ....
};

bool console_progress_indicator::
print_status (
  double cur,
  bool always_print
)
{
  ....
  if (!seen_first_val)
  {
    start_time = cur_time;
    last_time = cur_time;
    first_val = cur;
    seen_first_val = true;  // <=
    return false;
  }
  ....
}

Popular related articles
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…
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…
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 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…
PVS-Studio ROI

Date: 01.30.2019

Author: Andrey Karpov

Occasionally, we're asked a question, what monetary value the company will receive from using PVS-Studio. We decided to draw up a response in the form of an article and provide tables, which will sho…
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…
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…
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…
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…
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…

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