Examples of errors detected by the V601 diagnostic.


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


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;