From aadd9333dc1a22e69db27fbb4da30157022705b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20P=C3=A9rez?= Date: Fri, 22 Jan 2016 08:31:07 +0100 Subject: [PATCH] Virtual destructor for base class "Print" Abstract classes must have virtual destructors, so when you delete an object through a pointer the proper destructor can be called. Avoids two compiler warnings in some situations: - deleting object of abstract class type 'Print' which has non-virtual destructor will cause undefined behaviour [-Wdelete-non-virtual-dtor] - deleting object of polymorphic class type '...' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor] More info: http://stackoverflow.com/questions/461203/when-to-use-virtual-destructors --- hardware/arduino/avr/cores/arduino/Print.h | 1 + 1 file changed, 1 insertion(+) diff --git a/hardware/arduino/avr/cores/arduino/Print.h b/hardware/arduino/avr/cores/arduino/Print.h index 7b53aa4d17e..4108390973b 100644 --- a/hardware/arduino/avr/cores/arduino/Print.h +++ b/hardware/arduino/avr/cores/arduino/Print.h @@ -41,6 +41,7 @@ class Print void setWriteError(int err = 1) { write_error = err; } public: Print() : write_error(0) {} + virtual ~Print() {} int getWriteError() { return write_error; } void clearWriteError() { setWriteError(0); }