Examples of errors detected by the V746 diagnostic.


V746. Object slicing. An exception should be caught by reference rather than by value.


Oracle VM Virtual Box

V746 Object slicing. An exception should be caught by reference rather than by value. extpackutil.cpp 257


RTCString *VBoxExtPackLoadDesc(....)
{
  ....
  xml::XmlFileParser  Parser;
  try
  {
    Parser.read(szFilePath, Doc);
  }
  catch (xml::XmlError Err) // <=
  {
    return new RTCString(Err.what());
  }
  ....
}

Similar errors can be found in some other places:

  • V746 Object slicing. An exception should be caught by reference rather than by value. extpackutil.cpp 330

OpenToonz

V746 Object slicing. An exception should be caught by reference rather than by value. iocommand.cpp 1620


bool IoCmd::saveLevel(....)
{
  ....
  try {
    sl->save(fp, TFilePath(), overwritePalette);
  } catch (TSystemException se) { // <=
    QApplication::restoreOverrideCursor();
    MsgBox(WARNING, QString::fromStdWString(se.getMessage()));
    return false;
  } catch (...) {
    ....
  }
  ....
}

Similar errors can be found in some other places:

  • V746 Object slicing. An exception should be caught by reference rather than by value. iocommand.cpp 2650
  • V746 Object slicing. An exception should be caught by reference rather than by value. projectpopup.cpp 522
  • V746 Object slicing. An exception should be caught by reference rather than by value. projectpopup.cpp 537
  • And 8 additional diagnostic messages.

Open X-Ray Engine

V746 Object slicing. An exception should be caught by reference rather than by value. object_item_script.cpp 39


ObjectFactory::ServerObjectBaseClass *
CObjectItemScript::server_object    (LPCSTR section) const
{
  ObjectFactory::ServerObjectBaseClass *object = nullptr;

  try {
    object = m_server_creator(section);
  }
  catch(std::exception e) {
    Msg("Exception [%s] raised while creating server object "
        "from section [%s]", e.what(),section);
    return        (0);
  }
  ....
}

Notepad++

V746 Object slicing. An exception should be caught by reference rather than by value. filedialog.cpp 183


TCHAR* FileDialog::doOpenSingleFileDlg()
{
  ....
  try {
    fn = ::GetOpenFileName(&_ofn)?_fileName:NULL;

    if (params->getNppGUI()._openSaveDir == dir_last)
    {
      ::GetCurrentDirectory(MAX_PATH, dir);
      params->setWorkingDir(dir);
    }
  } catch(std::exception e) {                             // <=
    ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
  } catch(...) {
    ::MessageBox(NULL, TEXT("....!!!"), TEXT(""), MB_OK);
  }

  ::SetCurrentDirectory(dir);

  return (fn);
}

Scilab

V746 Object slicing. An exception should be caught by reference rather than by value. sci_scinotes.cpp 48


int sci_scinotes(char * fname, void* pvApiCtx)
{
  ....
  try
  {
    callSciNotesW(NULL, 0);
  }
  catch (GiwsException::JniCallMethodException exception)
  {
    Scierror(999, "%s: %s\n", fname,
      exception.getJavaDescription().c_str());
  }
  catch (GiwsException::JniException exception)
  {
    Scierror(999, "%s: %s\n", fname,
      exception.whatStr().c_str());
  }
  ....
}

Similar errors can be found in some other places:

  • V746 Object slicing. An exception should be caught by reference rather than by value. sci_builddoc.cpp 270
  • V746 Object slicing. An exception should be caught by reference rather than by value. sci_closescinotesfromscilab.cpp 45
  • V746 Object slicing. An exception should be caught by reference rather than by value. sci_closescinotesfromscilab.cpp 50
  • And 9 additional diagnostic messages.

Tizen

V746 Object slicing. An exception should be caught by reference rather than by value. CAudioInput.cpp 225


void CAudioInput::initialize() throw(CAudioError) {
  ....
  } catch (CAudioError err) {
    finalize();
    throw err;
  }
}

Similar errors can be found in some other places:

  • V746 Object slicing. An exception should be caught by reference rather than by value. CAudioInput.cpp 298
  • V746 Object slicing. An exception should be caught by reference rather than by value. CAudioInput.cpp 334
  • V746 Object slicing. An exception should be caught by reference rather than by value. CAudioInput.cpp 368
  • And 28 additional diagnostic messages.

Rosegarden

V746 Object slicing. An exception should be caught by reference rather than by value. MupExporter.cpp 197


timeT MupExporter::writeBar(....)
{
  ....
  try {
      // tuplet compensation, etc
      Note::Type type = e->get<Int>(NOTE_TYPE);
      int dots = e->get
                 <Int>(NOTE_DOTS);
      duration = Note(type, dots).getDuration();
  } catch (Exception e) { // no properties
      RG_WARNING << "WARNING: ...: " << e.getMessage();
  }
  ....
}

class BadSoundFileException : public Exception



Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;
We use cookies for the analysis of events to improve our content and make user interaction more convenient. By continuing the view of our web-pages you accept the terms of using these files. You can find out more about cookie-files and privacy policy or close the notification, by clicking on the button. Learn More →
Do not show again