[cfe-dev] Bug? This code should be clearly rejected!

Wilhelm wilhelm.meier at fh-kl.de
Fri Mar 27 03:26:31 PDT 2015


Hi all,

why does this wrong code compile with clang++ 3.6 (g++ rejects it
correctly)?

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);
}

-- 
Wilhelm



More information about the cfe-dev mailing list