Detecting / warning about missing key function?

We had a class without any key function.

It was working fine on most platforms but on the Clang-based Android builds we encountered problems like this. As described in the example on Stack Overflow and in our own case, the problem is only visible at runtime when dynamic_cast returns 0.

Can anybody clarify why this appeared to be working fine on other platforms but it is troublesome using Clang in the NDK?

Is there any way Clang can generate a warning at compile time?

In our own case, we found that the base class destructor was defined inline. We could solve the problem by moving the destructor definition to a source file or by adding the virtual modifier to another member function.

Hi,

We seem to have a warning: -Wweak-vtables, here is an example Compiler Explorer

Would that help?

Best, Vassil