<html>
<head>
<base href="http://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 --- - Member function pointer resolution confused by templates"
href="http://llvm.org/bugs/show_bug.cgi?id=16859">16859</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Member function pointer resolution confused by templates
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>llvm-bugs@quasiparticle.net
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=11019" name="attach_11019" title="Templated member function pointer resolution testcase">attachment 11019</a> <a href="attachment.cgi?id=11019&action=edit" title="Templated member function pointer resolution testcase">[details]</a></span>
Templated member function pointer resolution testcase
Member function pointer resolution in function calls seems to be confused by
templates. Given a class with two members:
struct X {
int x(int, int) { return 1; }
template<int>
int x(int) { return 2; }
};
and a resolution template that matches only on member function pointers with
two arguments:
template<class R, class C, class Arg1, class Arg2>
auto fn2(R (C::*p)(Arg1, Arg2))
-> R (C::*)(Arg1, Arg2)
{
return p;
}
I cannot resolve a member function pointer of X using fn2, e.g. fn2(&X::x)
results in a compile-time error. Qualifying the member function pointer
beforehand, i.e. fn2((int (X::*)(int, int)) &X::x) compiles fine.
GCC resolves the member function pointer as expected, i.e. the expression above
yields a pointer-to-member with two function arguments.
See the attached file for full testcase.
Expected output: 11
Actual output: compile time error
test.cpp:21:12: error: no matching function for call to 'fn2'
auto fn = fn2(&X::x);
^~~
test.cpp:12:6: note: candidate template ignored: couldn't infer template
argument 'R'
auto fn2(R (C::*p)(Arg1, Arg2))
^
1 error generated.</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>