abseil / abseil/abseil-cpp

Abstract class `CommandLineFlag` has non-virtual destructor

未關閉
#1,294 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
C++
星號
18.1k
分支
3.2k
平均合併
20 小時 36 分鐘
30 天內合併 PR
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 摘要。