Gcc 4.3.0 diagnoses the line marked "<<< error? <<<" in the program below.
I'd like to believe the program is well-formed and that the compiler should
be able to correctly deduce the template arguments from the initialed
expression without explicitly providing the template argument list.
template <class T> void f (T) { }
template <class T> void g (T&) { }
template <class T> void h (T&&) { }
int main ()
{
{ void (*pf)(int) = &f; } // okay
{ void (*pf)(int&) = &f; } // okay
{ void (*pf)(int&&) = &f; } // okay
{ void (*pf)(int&) = &g; } // okay
{ void (*pf)(int&&) = &h; } // okay
{ void (*pf)(int&) = &h; } // <<< error? <<<
{ void (*pf)(int&) = &h<int&>; } // okay
// { void (*pf)(int&&) = &h<int&>; } // error!
// { void (*pf)(int&&&) = &h<int&>; } // error!
}
t.cpp: In function int main():
t.cpp:14: error: no matches converting function h to type void (*)(int&)
t.cpp:3: error: candidates are: template<class T> void h(T&&)
--
Summary: error deducing template argument taking the address of
rvalue reference template
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sebor at roguewave dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36816