arduino / arduino/ArduinoCore-API

Missing virtual destructor for `Print` class

オープン
#256 コメント 0 件 リアクション 0 件 担当者 0 名 @andreagilardoni が担当を希望しています GitHub で見る
bug
主要言語
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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。