Examples of errors detected by the V596 diagnostic

V596. The object was created but it is not being used. The 'throw' keyword could be missing.


Multi Theft Auto

V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw InvalidRequestException(FOO); fallistheader.cpp 74


class CEGUIEXPORT InvalidRequestException : public Exception
{
  ....
};

ListHeaderSegment*
FalagardListHeader::createNewSegment(const String& name) const
{
  // make sure this has been set
  if (d_segmentWidgetType.empty())
  {
    InvalidRequestException(
      "FalagardListHeader::createNewSegment - "
      "Segment widget type has not been set!");
  }

  return ....;
}

Most likely this is what should be written here: throw InvalidRequestException(....);


Multi Theft Auto

V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw length_error(FOO); ceguistring.cpp 59


bool String::grow(size_type new_size)
{
  // check for too big
  if (max_size() <= new_size)
    std::length_error(
      "Resulting CEGUI::String would be too big");
  ....
}

Most likely this is what should be written here: throw std::length_error("Resulting CEGUI::String would be too big");


OpenMS

V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw ConversionError(FOO); xmlhandler.h 247


inline UInt asUInt_(const String & in)
{
  UInt res = 0;
  try
  {
    Int tmp = in.toInt();
    if (tmp < 0)
    {
      Exception::ConversionError(__FILE__, __LINE__,
                                 __PRETTY_FUNCTION__, "");
    }
    res = UInt(tmp);
  }
  catch (Exception::ConversionError)
  {
    error(LOAD,
          String("UInt conversion error of \"") + in + "\"");
  }
  return res;
}

Identical errors can be found in some other places:

  • V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw InvalidSize(FOO); inclusionexclusionlist.c 281
  • V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw MissingInformation(FOO); inclusionexclusionlist.c 285
  • V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw FileNotFound(FOO); precursorionselectionpreprocessing.c 257
  • And 8 additional diagnostic messages.

Geant4 software

V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw G4HadronicException(FOO); G4had_mod_util g4generalphasespacedecay.hh 116


inline G4double G4GeneralPhaseSpaceDecay::Pmx(
   G4double e, G4double p1, G4double p2)
{
  // calculate momentum of daughter particles in two-body decay
  if (e-p1-p2 < 0 )
  {
    G4HadronicException(__FILE__, __LINE__,
      "G4GeneralPhaseSpaceDecay::Pmx energy in "
      "cms > mass1+mass2");
  }
  ....
}

Most likely this is what should be written here: throw G4HadronicException(__FILE__, __LINE__, ....);

Identical errors can be found in some other places:

  • V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw G4HadronicException(FOO); _G4processes-archive g4neutronhpthermalscattering.cc 436
  • V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw G4HadronicException(FOO); _G4processes-archive g4neutronhpthermalscattering.cc 495
  • V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw G4HadronicException(FOO); _G4processes-archive g4neutronhpthermalscattering.cc 506
  • And 1 additional diagnostic messages.

FlightGear

V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw sg_exception(FOO); root.cxx 239


class sg_throwable : public std::exception { .... };
class sg_exception : public sg_throwable { .... };

void Root::scheduleToUpdate(Install* aInstall)
{
  if (!aInstall) {
    sg_exception("missing argument to scheduleToUpdate");
  }
  ....
}

OpenMW

V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw logic_error(FOO); components exprparser.cpp 101


void ExprParser::replaceBinaryOperands()
{
  ....
  if (t1==t2)
    mOperands.push_back (t1);
  else if (t1=='f' || t2=='f')
    mOperands.push_back ('f');
  else
    std::logic_error ("failed to determine result operand type");
}

FreeCAD

V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw Exception(FOO); waypointpyimp.cpp 231


void WaypointPy::setTool(Py::Int arg)
{
  if((int)arg.operator long() > 0)
    getWaypointPtr()->Tool = (int)arg.operator long();
  else
    Base::Exception("negativ tool not allowed!");
}

Identical errors can be found in some other places:

  • V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw Exception(FOO); application.cpp 274
  • V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw Exception(FOO); fileinfo.cpp 519
  • V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw Exception(FOO); waypointpyimp.cpp 244
  • And 1 additional diagnostic messages.

Computational Network Toolkit

V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw runtime_error(FOO); simplenetworkbuilder.cpp 1578


template <class ElemType>
ComputationNetworkPtr SimpleNetworkBuilder<ElemType>::
  BuildNetworkFromDbnFile(const std::wstring& dbnModelFileName)
{
  ....
  if (this->m_outputLayerSize >= 0)
    outputLayerSize = this->m_outputLayerSize;
  else if (m_layerSizes.size() > 0)
    m_layerSizes[m_layerSizes.size() - 1];
  else
    std::runtime_error("Output layer size must be...");     // <=
  ....
}

OpenToonz

V596 The object was created but it is not being used. The 'throw' keyword could be missing: throw domain_error(FOO); pluginhost.cpp 1486


void Loader::doLoad(const QString &file)
{
  ....
  int ret = pi->ini_(host);
  if (ret) {
    delete host;
    std::domain_error("failed initialized: error on ....");
  }
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;