This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Overload resolution compilation error


On Thu, 19 Jul 2007 12:59:09 -0300, Rodolfo Schulz de Lima wrote
> Hi, the code below doesn't compile with gcc-4.2, with the following error:
> 
> test.cpp: In function ?int main()?:
> test.cpp:19: error: no matching function for call to 
> ?call(<unresolved overloaded function type>)?
> 
> It compiles and runs fine with Visual Studio 2005. I think the 
> compiler should see that if I'm calling the non-templated 'print' 
> function and there's no other non-templated 'print' overload, it 
> should use 'void print()', with no ambiguity.
> 
Since the sub-expression `&print' is not a call expression,
the overload resolution mechanism will not select the non-template version 
first.
And the function templates can be instantiated without <>,
so the C++ compiler is confused.

This problem can be reduced to:
==========
void foo() { }
template<class T> void foo() { }

int main()
{
        &foo;
}
==========

It can help you to understand what's happend.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]