<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Template contsructor isntantiates invalid copy constructor"
href="https://bugs.llvm.org/show_bug.cgi?id=48538">48538</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Template contsructor isntantiates invalid copy constructor
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>stinkingmadgod@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>#include<type_traits>
template<typename T>
struct S
{
template<typename U = int,
std::enable_if_t<std::is_const_v<T>, U> = 0>
S(S<std::remove_const_t<T>>) {}
};
void foo(S<char>) {}
Will yield the error
<source>:8:32: error: copy constructor must pass its first argument by
reference
S(S<std::remove_const_t<T>>) {}
^
const &
<source>:11:17: note: in instantiation of template class 'S<char>' requested
here
void foo(S<char>)
I believe the snippet is well-formed due to either [class.copy.ctor]/5
<span class="quote">> A declaration of a constructor for a class X is ill-formed if its first parameter is of type cv X and
> either there are no other parameters or else all other parameters have default arguments.
> A member function template is never instantiated to produce such a constructor signature.</span >
Or simply because it should SFINAE away, the constructor is dependent.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>