Open ArturZiolkowski1999 opened 2 years ago
This would make apps take up more space than they do now. The warning is a false positive.
Adafruit_GFX
objects are trivially destructible. There's no reason to declare a user-defined destructor, other than to maybe mark it as virtual
. All data members in an Adafruit_GFX
are trivial.
Adafruit_GFX
objects are rarely held by pointers or destroyed by apps. They're just declared as static-duration namespace-scope objects typically, and used in setup() and loop() functions. There's no destructor call, as Arduino apps have no exit sequence.
Because the sketch doesn't actually destroy it, the linker can currently optimize the destructor out.
But if it's virtual
, the destructor becomes part of the type's __vtbl
. So at that point there's a reference pinning that destructor's address to the final executable and it can't be optimized away. I believe this will cause executables to grow slightly in size. -W
warnings are nice to have, but size-constrained apps shouldn't have to take up more RAM to silence a false positive.
when deleting Adafruit_SSD1306 object, i've got this warning: warning: deleting object of polymorphic class type 'Adafruit_SSD1306' which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]. I suggest to create Adafruit_GFX destructor.