Examples of errors detected by the V599 diagnostic

V599. The virtual destructor is not present, although the 'Foo' class contains virtual functions.


WinMerge

V599 The virtual destructor is not present, although the 'CompareOptions' class contains virtual functions. Merge diffcontext.cpp 90


CompareOptions *m_pCompareOptions;

CDiffContext::~CDiffContext()
{
  ...
  delete m_pCompareOptions;
  ...
}

class CompareOptions
{
public:
  CompareOptions();
  CompareOptions(const CompareOptions & options);
  virtual void SetFromDiffOptions(const DIFFOPTIONS & options);

  enum WhitespaceIgnoreChoices m_ignoreWhitespace;
  bool m_bIgnoreBlankLines;
  bool m_bIgnoreCase;
  bool m_bIgnoreEOLDifference;
};

class DiffutilsOptions : public CompareOptions
{
  ...
};

Multi Theft Auto

V599 The virtual destructor is not present, although the 'CKeyBind' class contains virtual functions. ckeybinds.cpp 488


class CKeyBind
{
  //A virtual destructor is absent
  ....
};

class CKeyBindWithState: public CKeyBind { .... };
class CGTAControlBind: public CKeyBind { .... };

void CKeyBinds::Remove ( CKeyBind* pKeyBind )
{
  if ( m_bProcessingKeyStroke ) pKeyBind->beingDeleted = true;
  else
  {
    m_pList->remove ( pKeyBind );
    delete pKeyBind;
  }
}

Identical errors can be found in some other places:

  • V599 The destructor was not declared as a virtual one, although the 'CChat' class contains virtual functions. cgui.cpp 173
  • V599 The virtual destructor is not present, although the 'CComplexEasingFunction' class contains virtual functions. ceasingcurve.cpp 151
  • V599 The virtual destructor is not present, although the 'CComplexEasingFunction' class contains virtual functions. ceasingcurve.cpp 168
  • And 10 additional diagnostic messages.

ffdshow

V599 The virtual destructor is not present, although the 'TsubtitleParserBase' class contains virtual functions. tsubtitlestextpintext.cpp 41


class TsubtitleParser : public TsubtitleParserBase { .... }
class TsubtitleParserSubrip09 : public TsubtitleParser { .... }

// Factory Pattern
TsubtitleParserBase* TsubtitleParserBase::getParser(
  int format, double fps, const TsubtitlesSettings *cfg,
  const Tconfig *ffcfg, Tsubreader *subreader,
  bool utf8, bool isEmbedded)
{
  switch (format & Tsubreader::SUB_FORMATMASK) {
  case Tsubreader::SUB_MICRODVD  :
    return new TsubtitleParserMicrodvd(...);
  case Tsubreader::SUB_SUBRIP    :
    return new TsubtitleParserSubrip(...);
  case Tsubreader::SUB_SUBVIEWER :
    return new TsubtitleParserSubviewer(...);
  case Tsubreader::SUB_SAMI      :
    return new TsubtitleParserSami(...);
  case Tsubreader::SUB_VPLAYER   :
    return new TsubtitleParserVplayer(...);
  case Tsubreader::SUB_RT        :
    return new TsubtitleParserRt(...);
  case Tsubreader::SUB_SSA       :
    return new TsubtitleParserSSA(..., isEmbedded);
  case Tsubreader::SUB_DUNNOWHAT :
    return new TsubtitleParserDunnowhat(...);
  case Tsubreader::SUB_MPSUB     :
    return new TsubtitleParserMPsub(...);
  case Tsubreader::SUB_AQTITLE   :
    return new TsubtitleParserAqt(...);
  case Tsubreader::SUB_SUBVIEWER2:
    return new TsubtitleParserSubviewer2(...);
  case Tsubreader::SUB_SUBRIP09  :
    return new TsubtitleParserSubrip09(...);
  case Tsubreader::SUB_MPL2      :
    return new TsubtitleParserMPL2(...);
  default:
    return NULL;
  }
}

TsubtitleParserBase *parser;
parser = TsubtitleParserBase::getParser(
  type, fps1000 / 1000.0, cfg, ffcfg, subs, utf8, true);

TsubtitlesTextpinText::~TsubtitlesTextpinText()
{
  if (parser) {
    delete parser;
  }
}

A destructor is absent in TsubtitleParserBase. A virtual destructor is needed.


Trans-Proteomic Pipeline

V599 The virtual destructor is not present, although the 'DiscriminantFunction' class contains virtual functions. discrimvalmixturedistr.cxx 206


class DiscriminantFunction {
public:
  DiscriminantFunction(int charge);
  virtual Boolean isComputable(SearchResult* result) = 0;
  virtual double getDiscriminantScore(SearchResult* result) = 0;
  virtual void error(int charge);
protected:
  int charge_;
  double const_;
}; // class

class CometDiscrimFunction : public DiscriminantFunction;
class CruxDiscrimFunction : public DiscriminantFunction;
class InspectDiscrimFunction : public DiscriminantFunction;
.....

class DiscrimValMixtureDistr : public MixtureDistr {
  ....
  DiscriminantFunction* discrim_func_;
  ....
};

DiscrimValMixtureDistr::~DiscrimValMixtureDistr() {
  delete[] posinit_;
  delete[] neginit_;
  delete discrim_func_;
}

VirtualDub

V599 The destructor was not declared as a virtual one, although the 'VDDialogBaseW32' class contains virtual functions. VirtualDub gui.cpp 997


class VDDialogBaseW32 {
  ....
  ~VDDialogBaseW32();
  ....
  virtual INT_PTR DlgProc(....) = 0;
  virtual bool PreNCDestroy();
  ....
}

class VDDialogAudioFilterFormatConvConfig :
  public VDDialogBaseW32
{ .... };

INT_PTR CALLBACK VDDialogBaseW32::StaticDlgProc(....) {
  VDDialogBaseW32 *pThis =
    (VDDialogBaseW32 *)GetWindowLongPtr(hwnd, DWLP_USER);
  ....
  delete pThis;
  ....
}

Identical errors can be found in some other places:

  • V599 The virtual destructor is not present, although the 'VDMPEGAudioPolyphaseFilter' class contains virtual functions. Priss engine.cpp 35

Source Engine SDK

V599 The destructor was not declared as a virtual one, although the 'CFlashlightEffect' class contains virtual functions. Client (HL2) c_baseplayer.cpp 454


class CFlashlightEffect
{
  ....
  ~CFlashlightEffect();
  ....
};

class CHeadlightEffect : public CFlashlightEffect { .... };

CFlashlightEffect *m_pFlashlight;

C_BasePlayer::~C_BasePlayer()
{
  ....
  delete m_pFlashlight;
}

Identical errors can be found in some other places:

  • V599 The virtual destructor is not present, although the 'IHaptics' class contains virtual functions. Client (HL2) haptic_utils.cpp 150
  • V599 The destructor was not declared as a virtual one, although the 'CBaseCommand' class contains virtual functions. Client (HL2) scratchpad3d.cpp 205
  • V599 The virtual destructor is not present, although the 'CStriderMinigun' class contains virtual functions. Server (HL2) npc_strider.cpp 432
  • And 3 additional diagnostic messages.

Synergy

V599 The destructor was not declared as a virtual one, although the 'CKeyMap' class contains virtual functions. ckeystate.cpp 408


class CKeyMap {
public:
  CKeyMap();
  ~CKeyMap();
  ....
  virtual void swap(CKeyMap&);
  virtual void addHalfDuplexModifier(KeyID key);
  virtual void finish();
  ....
};

class CMockKeyMap : public CKeyMap { .... };

CKeyMap* m_keyMapPtr;

CKeyState::~CKeyState()
{
  if (m_keyMapPtr)
    delete m_keyMapPtr;
}

ANGLE

V599 The destructor was not declared as a virtual one, although the 'Context' class contains virtual functions. context.cpp 2955


class Context
{
  ....
  ~Context();
  ....
  virtual void markContextLost();
  ....
};

void glDestroyContext(gl::Context *context)
{
  delete context;

  if (context == gl::getContext())
  {
    gl::makeCurrent(NULL, NULL, NULL);
  }
}

Identical errors can be found in some other places:

  • V599 The destructor was not declared as a virtual one, although the 'Surface' class contains virtual functions. display.cpp 241
  • V599 The destructor was not declared as a virtual one, although the 'Surface' class contains virtual functions. display.cpp 354
  • V599 The destructor was not declared as a virtual one, although the 'Surface' class contains virtual functions. display.cpp 412

TortoiseGit

V599 The virtual destructor is not present, although the 'Command' class contains virtual functions. TortoiseGitProc tortoiseproc.cpp 497


class Command
{
  virtual bool Execute() = 0;
  ....
};

class SVNIgnoreCommand : public Command ....
class AddCommand : public Command ....
class AutoTextTestCommand : public Command ....

BOOL CTortoiseProcApp::InitInstance()
{
  ....
  Command * cmd = server.GetCommand(....);
  ....
  delete cmd;
  ....
}

Miranda NG

V599 The virtual destructor is not present, although the 'CNetClient' class contains virtual functions. YAMN pop3.h 23


class CNetClient
{
public:
  CNetClient(): Stopped(FALSE) {}
  virtual void Connect(const char* servername,const int port)=0;
  virtual void Send(const char *query)=0;
  virtual char* Recv(char *buf=NULL,int buflen=65536)=0;
  virtual void Disconnect()=0;
  virtual BOOL Connected()=0;
  virtual void SSLify()=0;
  ....
};

class CNLClient: public CNetClient { .... };

class CPop3Client
{
  ....

  class CNetClient *NetClient;

  ~CPop3Client() {
    if (NetClient != NULL) delete NetClient;
  }

  ....
};

Identical errors can be found in some other places:

  • V599 The destructor was not declared as a virtual one, although the 'CUpdProgress' class contains virtual functions. UInfoEx svc_refreshci.cpp 606
  • V599 The virtual destructor is not present, although the 'CNetClient' class contains virtual functions. YAMN pop3.cpp 42
  • V599 The virtual destructor is not present, although the 'FactoryBase' class contains virtual functions. HistoryStats column.cpp 30
  • And 1 additional diagnostic messages.

FreeCAD

V599 The virtual destructor is not present, although the 'Curve' class contains virtual functions. constraints.cpp 1442


class Curve
{
//a base class for all curve-based
//objects (line, circle/arc, ellipse/arc)  // <=
public:
  virtual DeriVector2 CalculateNormal(....) = 0;
  virtual int PushOwnParams(VEC_pD &pvec) = 0;
  virtual void ReconstructOnNewPvec (....) = 0;
  virtual Curve* Copy() = 0;
};

class Line: public Curve    // <=
{
public:
  Line(){}
  Point p1;
  Point p2;
  DeriVector2 CalculateNormal(Point &p, double* derivparam = 0);
  virtual int PushOwnParams(VEC_pD &pvec;);
  virtual void ReconstructOnNewPvec (VEC_pD &pvec, int &cnt;);
  virtual Line* Copy();
};

....

class ConstraintAngleViaPoint : public Constraint
{
private:
  inline double* angle() { return pvec[0]; };
  Curve* crv1;  // <=
  Curve* crv2;  // <=
  ....
};

ConstraintAngleViaPoint::~ConstraintAngleViaPoint()
{
  delete crv1; crv1 = 0; // <=
  delete crv2; crv2 = 0; // <=
}

GINV

V599 The destructor was not declared as a virtual one, although the 'INParameterGmpZAux' class contains virtual functions. igcdzippel.cpp 212


class INParameterGmpZAux {
  ....
  ~INParameterGmpZAux() {
    mHead.clear();
  }
  ....
  virtual void set(const INParameterGmpZAux& a);
  ....
};

void IGcdZippel::getMinimum(IList<INParameterGmpZAux*>& list,
    INParameterGmpZAux& minimum) {
{
  ....
  INParameterGmpZAux* result = (*it);
  ....
  delete result;
}

Unreal Engine 4

V599 The virtual destructor is not present, although the 'FD3D12Device' class contains virtual functions. d3d12device.cpp 448


class FD3D12Device
{
  ....
  virtual void InitD3DDevice();
  virtual void CleanupD3DDevice();
  ....
  // Destructor is not declared
  ....
};

FD3D12Device* MainDevice;

void FD3D12DynamicRHI::Shutdown()
{
  ....
  delete(MainDevice);
  ....
}

Computational Network Toolkit

V599 The virtual destructor is not present, although the 'IDataWriter' class contains virtual functions. datawriter.cpp 47


template <class ElemType>
class DATAWRITER_API IDataWriter
{
public:
    typedef std::string LabelType;
    typedef unsigned int LabelIdType;

    virtual void Init(....) = 0;
    virtual void Init(....) = 0;
    virtual void Destroy() = 0;
    virtual void GetSections(....) = 0;
    virtual bool SaveData(....) = 0;
    virtual void SaveMapping(....) = 0;
};

IDataWriter<ElemType>* m_dataWriter;
....
template <class ElemType>
void DataWriter<ElemType>::Destroy()
{
    delete m_dataWriter; // <= V599 warning
    m_dataWriter = NULL;
}

OpenToonz

V599 The destructor was not declared as a virtual one, although the 'TTileSet' class contains virtual functions. cellselection.cpp 891


class DVAPI TTileSet
{
  ....
protected:
  TDimension m_srcImageSize;

  typedef std::vector<Tile *> Tiles;
  Tiles m_tiles;

public:
  TTileSet(const TDimension &dim) : m_srcImageSize(dim)
  {
  }
  ~TTileSet();      // <=
  ....
  virtual void add(const TRasterP &ras, TRect rect) = 0;
  ....
  virtual TTileSet *clone() const = 0;
};

void redo() const
{
  insertLevelAndFrameIfNeeded();
  TTileSet *tiles;  // <=
  bool isLevelCreated;
  pasteRasterImageInCellWithoutUndo(...., &tiles, ....);
  delete tiles;     // <=
  TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}

class DVAPI TTileSetCM32 : public TTileSet class DVAPI TTileSetCM32 : public TTileSet class DVAPI TTileSetFullColor : public TTileSet class DVAPI Tile : public TTileSet::Tile

Identical errors can be found in some other places:

  • V599 The virtual destructor is not present, although the 'MessageParser' class contains virtual functions. tipcsrv.cpp 91
  • V599 The virtual destructor is not present, although the 'ColumnToCurveMapper' class contains virtual functions. functionselection.cpp 278


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;