<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - Class template member function out-of-line definition dependent parameter uses declaration topmost cv-qualification"
href="https://llvm.org/bugs/show_bug.cgi?id=30365">30365</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Class template member function out-of-line definition dependent parameter uses declaration topmost cv-qualification
</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>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>ed@catmur.co.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>In a class template member function out-of-line definition, with a parameter
dependent on class template parameters and differing in topmost
cv-qualification between declaration and definition, clang uses the parameter
type of the declaration rather than the parameter type of the definition,
incorrectly accepting this program:
template<class T> struct A { void f(typename T::U); };
template<class T> void A<T>::f(typename T::U const i) { i = 1; } // no error
struct X { using U = int; };
int main() { A<X>{}.f(0); }
Expected error:
cannot assign to variable 'i' with const-qualified type 'const typename X::U'
(aka 'const int')
If the cv-qualifiers are swapped (const present on the declaration, not on the
definition), clang incorrectly rejects the program:
template<class T> struct A { void f(typename T::U const); };
template<class T> void A<T>::f(typename T::U i) { i = 1; } // error
struct X { using U = int; };
int main() { A<X>{}.f(0); }
gcc and MSVC compile both these correctly; ICC has the same bug as clang.
Tested versions 3.0-3.9.
References: [class.mfct]/1, [dcl.fct]/5.</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>