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 摘要。