bentaisan bentaisan - 1 year ago 50
C++ Question

How to delete an object of a polymorphic class type that has no virtual destructor

I am getting the following error when I try to compile some code from a Third-party SDK.

*Description Resource Path Location Type
deleting object of polymorphic class type ‘Vendor_sys::VendorCode’ which has non-virtual destructor might cause undefined behaviour [-Werror=delete-non-virtual-dtor] PnServer.cpp /PCounter line 467 C/C++ Problem*





I do not know if its possible to satisfy this condition with only partial knowledge of the Vendor's SDK, where most of the heavy lifting is done in a dll or library object.

My build environment is Eclipse Juno with gpp.

I searched in Google for the error message and did not find any instances of this error.

So, if I cannot modify the black box part of the vendor code, what are my options?

Here is the code that is failing during the make process:

delete pData->unit;

Answer Source

Actually, I removed the -Werror switch from the compile and the program compiled.

Now, the messages are just warnings.

I will send a bug report to the vendor.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download