Skip to content

Commit 473cfeb

Browse files
authored
Missing virtual destructor results in compiler warning (#153)
When `delete`ing an EthernetClient object, the compiler throws the following warning: `warning: deleting object of polymorphic class type 'EthernetClient' which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]` Adding a virtual destructor solves this problem, see also here: https://stackoverflow.com/questions/43282826/suppress-delete-non-virtual-dtor-warning-when-using-a-protected-non-virtual-dest
1 parent f0c0e37 commit 473cfeb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/Ethernet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class EthernetClient : public Client {
215215
public:
216216
EthernetClient() : sockindex(MAX_SOCK_NUM), _timeout(1000) { }
217217
EthernetClient(uint8_t s) : sockindex(s), _timeout(1000) { }
218+
virtual ~EthernetClient() {};
218219

219220
uint8_t status();
220221
virtual int connect(IPAddress ip, uint16_t port);

0 commit comments

Comments
 (0)