Skip to content

Commit fbb5412

Browse files
authored
Shut up warnings clang with libstdc++ emits about non-virtual destructors (#1012)
It complains a lot about non-final classes (structs) derived from KVEntry having virtual functions but no virtual destructor, which in std::optional code (that explicitly calls the destructor somewhere) could theoretically lead to the wrong destructor being called (that of the struct directly derived from KVEntry instead of the one of a hypothetical class derived from that struct that might actually need its destructor called). This doesn't matter in practice because 1. those classes don't have any implemented constructors that need to do anything 2. no further classes are derived from those that are derived from KVEntry So (I think!) these warnings are only hypothetical, but still annoying. Apparently this does not happen if Clang uses libc++ or MSVCs C++ stdlib (in the ClangCL case), but only with libstdc++, maybe even only with libstdc++ from GCC14, but that's the only version I have on my machine. Fixes #1011
1 parent b9218bc commit fbb5412

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.github/workflows/linux.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,28 @@ jobs:
5858
doc: OFF, jni: ON, loadtests: OpenGL+Vulkan, py: ON, tools: ON, tools_cts: ON,
5959
sse: ON, opencl: OFF
6060
}
61+
- name: Clang Debug
62+
os: ubuntu-22.04
63+
generator: Ninja
64+
arch: x86_64
65+
compiler: clang
66+
vk_sdk_ver: '1.3.290'
67+
options: {
68+
config: Debug,
69+
doc: OFF, jni: ON, loadtests: OpenGL+Vulkan, py: ON, tools: ON, tools_cts: OFF,
70+
sse: ON, opencl: OFF
71+
}
72+
- name: Clang Release
73+
os: ubuntu-22.04
74+
generator: Ninja
75+
arch: x86_64
76+
compiler: clang
77+
vk_sdk_ver: '1.3.290'
78+
options: {
79+
config: Release,
80+
doc: OFF, jni: ON, loadtests: OpenGL+Vulkan, py: ON, tools: ON, tools_cts: OFF,
81+
sse: ON, opencl: OFF
82+
}
6183
- name: Package (x86_64)
6284
os: ubuntu-22.04
6385
generator: Ninja

tools/ktx/command_compare.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,10 @@ struct KVEntry {
18461846
char* value;
18471847
ktx_uint32_t valueLen;
18481848

1849+
// shut up clang's complaints about derived classes
1850+
// that have virtual functions but non-virtual destructor
1851+
virtual ~KVEntry() {}
1852+
18491853
template <typename T>
18501854
static std::optional<T> load(ktxHashListEntry* entry) {
18511855
if (entry) {

0 commit comments

Comments
 (0)