[llvm-bugs] [Bug 48365] Compiler is using wrong template argument when a child class calls a templated constructor of a template class.
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Dec 2 14:50:17 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48365
David Blaikie <dblaikie at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
CC| |dblaikie at gmail.com
Status|NEW |RESOLVED
--- Comment #1 from David Blaikie <dblaikie at gmail.com> ---
Looks reasonable to me - the rest of the error message says:
"<source>:13:5: note: in instantiation of default argument for
'Base<Base<int>>' required here
Base(const U& v) {
^~~~~~~~~~~~~~~~~~
<source>:10:7: note: while substituting deduced template arguments into
function template 'Base' [with U = Base<int>, $1 = (no value)]
class Base {
^
<source>:17:7: note: while declaring the implicit copy constructor for 'Child'
class Child : public Base<int> {
^"
So it's not while trying to evaluate "Child child;"'s call to the "Child()"
ctor, which does correctly use the Base<int>::Base<float> ctor, but it's while
trying to declare Child's copy ctor - which, is the absence of any other ctor,
tries to use Base<int>::Base<Base<int>> to do the copy construction.
If you make the Base ctor not a valid ctor to use for copying (eg, by changing
its template parameter list to SFINAE out that option: "template <typename U,
typename = std::enable_if_t<!std::is_same_v<U, Base>>, typename = typename
CheckInt<U>::success>") then the build error goes away.
https://godbolt.org/z/6fGjhd
Similarly, if the ctor in question had an extra parameter - there would be no
ambiguity: https://godbolt.org/z/oqGxhq
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201202/b462f56e/attachment.html>
More information about the llvm-bugs
mailing list