-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
I'm trying to create a library that uses PubSubClient. I create a mqttClient = new PubSubClient
on initialization and I want to delete mqttClient
in some cases. However, my compiler (platformio) issues a warning "deleting object of polymorphic class type 'PubSubClient' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]".
As far as I understood the cause for this warning is that PubSubClient
class is inherited from Print
class, and there is no virtual destructor in Print
class. This is discussed in arduino/Arduino#4466 – this PR exists from 2016, however it is still not merged.
While most accurate solution will be adding virtual destructor to Print
base class, I can't see any advantages for PubSubClient
to be derived from Print class. I suggest to remove this inheritance and get rid of undefined behaviour.