arduino / arduino/ArduinoCore-API
Missing virtual destructor for `Print` class
- 主要语言
- C++
- 星标
- 306
- 派生
- 150
- PR 合并指标
- 30 天内没有已合并 PR
描述
### Description
Missing virtual destructor - memory leak and UB
### Environment
First found on R4, but it is general
### Current behavior
Warning while compiling sketch, possible UB.
```
packages/arduino/hardware/renesas_uno/1.5.0/libraries/WiFiS3/src/Modem.cpp: In destructor 'ModemClass::~ModemClass()':
packages/arduino/hardware/renesas_uno/1.5.0/libraries/WiFiS3/src/Modem.cpp:27:14: warning: deleting object of polymorphic
class type 'UART' which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]
delete _serial;
```
ModemClass extends Serial which extends Print.
### Expected behavior
no warnings
### Additional information
This class is very base class of all streams and other i/o components.
https://github.com/arduino/ArduinoCore-API/blob/4a02bfc0a924e1fec34c3bb82ffd5dfba7643a0c/api/Print.h#L35
贡献指南
这个仓库没有索引到贡献指南
调研方向
阅读 api/Print.h 中引用的声明,并审查链接的 pull request #218,以了解提议的更改。当 Modem.cpp 示例不再产生非虚析构函数警告或相关的未定义行为问题时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cpp
- 领域
- api, embedded-iot
- Issue 类型
- 缺陷
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 30/100