Thanks, Marc. Please consider this test code: void f(); template <typename T> void foo(const T); void Test() { foo(f); } int main(Test()); It compiles sucessfully for GCC 4.5. As you know, we are trying to add cv-qualifier on top of function type while template deduce happens. On Fri, Feb 18, 2011 at 11:38 PM, Marc Glisse <marc.glisse@xxxxxxxx> wrote: > On Fri, 18 Feb 2011, Ian Lance Taylor wrote: > >> zhang qingshan <steven.zhang54373@xxxxxxxxx> writes: >> >>> /* ------- test case -------------------*/ >>> void x(); >>> template <typename T> >>> void foo(const T*); >>> >>> int main() { >>> foo(x); >>> } >>> >>> GCC 4.5 complains: >>> >>> a.cpp: In function 'int main()': >>> a.cpp:6: error: no matching function for call to 'foo(void (&)())' >>> >>> It seems that, const T * is resolved as void (&)()); >>> >>> IMO, T --> void (), const T --> void (), const T * --> void (*)(), and >>> it should be leagle. >> >> You are confusing function pointers with pointers to data objects. They >> are not the same thing in C++. That is, a function pointer is not a >> special type of pointer. > > Well it still kind of is. Without the "const", the code compiles fine. But > the fact that a const qualifier on a function type is ignored seems not to > apply to template type deduction. > > (note that most compilers behave like g++ here, except for clang which > accepts the original code) > > -- > Marc Glisse > Consider this test case: void f(); template <typename T> foo(const T&); void Test() { foo(f); }