abseil / abseil/abseil-cpp

Abstract class `CommandLineFlag` has non-virtual destructor

オープン
#1,294 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
C++
スター
18.1k
フォーク
3.2k
平均マージ
20時間 36分
マージ済み PR(30日)
1

説明

The destructor of the class `CommandLineFlag` is missing the keyword `virtual` although this class has lots of pure virtual methods defining an interface. While this is generally a bad idea, this also results in compiler warnings if compiling the [webrtc-audio-processing](https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing) library (version 1.0) for instance.
The following is what GCC is complaining:
```
In file included from /usr/include/absl/flags/internal/flag.h:35,
from /usr/include/absl/flags/flag.h:39,
from ../webrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_tool.cc:15:
/usr/include/absl/flags/commandlineflag.h:62:7: warning: ‘class absl::debian1::CommandLineFlag’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
In file included from /usr/include/absl/flags/flag.h:39,
from ../webrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_tool.cc:15:
/usr/include/absl/flags/internal/flag.h:440:7: warning: base class ‘class absl::debian1::CommandLineFlag’ has accessible non-virtual destructor [-Wnon-virtual-dtor]
```

This bug can trivially be solved like that:
``` patch
--- a/absl/flags/commandlineflag.h
+++ b/absl/flags/commandlineflag.h
@@ -153,7 +153,7 @@
bool ParseFrom(absl::string_view value, std::string* error);

protected:
- ~CommandLineFlag() = default;
+ virtual ~CommandLineFlag() = default;

private:
friend class flags_internal::PrivateHandleAccessor;
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

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

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