Skip to content

Commit 0f10f89

Browse files
committed
Shut up warnings clang with libstdc++ emits about non-virt destructors
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.
1 parent 70ed9b9 commit 0f10f89

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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)