With regard to previous questions on this topic:
This a follow up of the question that I've asked recently: clang: no out-of-line virtual method definitions (pure abstract C++ class) and which was marked as duplicate of this question: What is the meaning of clang's -Wweak-vtables?. I don't think that that answered my question, so here I'm focusing on the very thing that puzzles me and that hasn't been answered yet.
My scenario:
I'm trying to compile the following simple C++ code using Clang-3.5:
test.h:
class A
{
public:
A();
virtual ~A() = 0;
};
test.cc
#include "test.h"
A::A() {;}
A::~A() {;}
The command that I use for compiling this (Linux, uname -r: 3.16.0-4-amd64):
$clang-3.5 -Wweak-vtables -std=c++11 -c test.cc
And the error that I get:
./test.h:1:7: warning: 'A' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Wweak-vtables]
The above code builds fine when class A is not pure abstract. The following code doesn't emit warnings, and the only change is that class A is no longer abstract:
test2.h:
class A
{
public:
A();
virtual ~A();
};
test2.cc
#include "test2.h"
A::A() {;}
A::~A() {;}
My question
What's so special about pure abstract classes that the above code triggers warnings in Clang?