TellowKrinkle via llvm-dev
2020-Aug-30 21:53 UTC
[llvm-dev] Clang/GCC overload resolution disagreement
Given the following code: struct A {}; struct B: public A { explicit B(A a) {} }; struct C: public B {}; B yay(const C& thing) { return B(thing); } Clang uses B’s copy constructor, while GCC refuses to compile, claiming an ambiguity between B’s copy constructor and the explicit B(A) constructor Which compiler is correct here? Live example: https://gcc.godbolt.org/z/3doW5d
David Blaikie via llvm-dev
2020-Aug-31 16:53 UTC
[llvm-dev] Clang/GCC overload resolution disagreement
Question's .probably more suitable for cfe-dev, rather than llvm-dev. On Sun, Aug 30, 2020 at 2:53 PM TellowKrinkle via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Given the following code: > > struct A {}; > struct B: public A { > explicit B(A a) {} > }; > struct C: public B {}; > B yay(const C& thing) { > return B(thing); > } > > Clang uses B’s copy constructor, while GCC refuses to compile, claiming an > ambiguity between B’s copy constructor and the explicit B(A) constructor > > Which compiler is correct here? > > Live example: https://gcc.godbolt.org/z/3doW5d > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200831/1a18416f/attachment.html>