It's a bit surprising to me that this program:
struct A {
virtual void a()=0;
};
struct B : public A {
void a() {}
};
int main() {
B b;
b.a(); // OK, call B::a()
b.A::a(); // linker error?
}
Gave me this error (gcc 4.4):
/tmp/ccfOGuBJ.o: In function `main':
test.cc:(.text+0x28): undefined reference to `A::a()'
collect2: ld returned 1 exit status
(clang 7.0.0)
Undefined symbols for architecture x86_64:
"A::a()", referenced from:
_main in test-440cc5.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I expected that attempting to call a pure function would give an explicit error, because it was declared as deleted, rather than an implicit error. Is there not a distinction in the standard between "function not in this translation unit," and "function not in any translation unit?"
It should be noted that attempting to directly call a pure virtual is not addressed in ยง10.4.