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

David Blaikie dblaikie at gmail.com
Fri Mar 27 09:15:32 PDT 2015


On Fri, Mar 27, 2015 at 3:26 AM, Wilhelm <wilhelm.meier at fh-kl.de> wrote:

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

Yep. Looks like a bug to me. I think we had the same bug for return types
of abstract classes too & that was fixed a few months ago. Seems we haven't
fully flushed out these issues...


>
> 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
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150327/46e483c9/attachment.html>


More information about the cfe-dev mailing list