why is clang ++ 3.6 compiling the following code (g ++ not)?
class Abc { public: virtual void foo() const = 0; virtual ~Abc() {} };
I am using clang 3.6 and gcc 4.9.2.
Why is a free function (correctly) rejected and the member function is not?
Any clues? Error in clang?
If I modify above:
class Abc { public: virtual void foo() const = 0; virtual ~Abc() {} }; class Impl : public Abc { public: void foo() const {} }; class B { public: void bar(Abc o) { o.foo(); } }; int main() { B b; Impl i; b.bar(i); }
I get
main.cc:16: undefined reference to `Abc :: foo () const '
Linker Error.
So the question is: why does clang ++ compile this incorrect code at all? I would say that this is a serious mistake!
source share