Add virtual destructor to avoid compiler warning on undefined behavior#557
Add virtual destructor to avoid compiler warning on undefined behavior#557gillesdegottex wants to merge 1 commit intoarduino:masterfrom gillesdegottex:virtdtor
Conversation
|
Memory usage change @ be75fe7
Click for full report table
Click for full report CSV |
per1234
left a comment
There was a problem hiding this comment.
Thanks for your pull request @gillesdegottex!
There is a related discussion here:
You can see here that the equivalent change was originally also proposed in arduino/ArduinoCore-API#218:
--- a/api/Server.h
+++ b/api/Server.h
@@ -25,6 +25,7 @@ namespace arduino {
class Server : public Print {
public:
+ virtual ~Server() {}
virtual void begin() = 0;
};However, the proposal was adjusted per this comment:
arduino/ArduinoCore-API#218 (comment)
It is enough to add virtual destructor to
Stream,Client,Server,HardwareI2CandHardwareSerialare inherited from
|
Oh, my bad, I didn't see this similar PR. I'll close mine then and see if I can bring any 2 cents useful for API#218. |
|
No worries. The goal of my comment was only to make sure the related work in the other repository was given consideration (I don't have enough expertise in C++ to make a judgement in the specific approach that should be taken in this matter). The intent behind the |
|
Thx for the detailed answer! |
The
Serverclass is virtual (begin()is not defined).Standard thus requires to have the destructor virtual, otherwise undefined behaviour is expected.
This PR suggest to fix this issue by adding a simple empty destructor.