http://llvm.org/bugs/show_bug.cgi?id=16859
Bug ID: 16859
Summary: Member function pointer resolution confused by
templates
Product: clang
Version: 3.3
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Created attachment 11019
--> http://llvm.org/bugs/attachment.cgi?id=11019&action=edit
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs