This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++ 2.95.2 cannot resolve a return-type template function overload
- To: "gcc bug list" <gcc-bugs at gcc dot gnu dot org>
- Subject: g++ 2.95.2 cannot resolve a return-type template function overload
- From: " " <sebor at my-Deja dot com>
- Date: Thu, 27 Jan 2000 16:27:21 -0800
- Cc: "John Pedretti" <pedretti at roguewave dot com>
- Organization: My Deja Email (http://www.my-deja.com:80)
Hi,
the program below gives an error with g++ 2.95.2. I believe since the second foo<>() matches exactly it is a "better match" than the first foo<>(). The program compiles fine with edg 2.42.
Thanks
Martin
$ cat test.cpp
template <class T, class U>
T foo (U)
{
return T ();
}
template <class T>
T foo (int)
{
return 1 + T ();
}
int main ()
{
return foo<int> (0);
}
$ g++ -c --pedantic -v test.cpp
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -pedantic -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) test.cpp /var/tmp/cc5ul2Dd.ii
GNU CPP version 2.95.2 19991024 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/../../../../include/g++-3
/usr/local/include
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/../../../../sparc-sun-solaris2.7/include
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/cc1plus /var/tmp/cc5ul2Dd.ii -quiet -dumpbase test.cc -pedantic -version -o /var/tmp/cc2urzBc.s
GNU C++ version 2.95.2 19991024 (release) (sparc-sun-solaris2.7) compiled by GNU C version 2.95.2 19991024 (release).
test.cpp: In function `int main()':
test.cpp:18: call of overloaded `foo (int)' is ambiguous
test.cpp:5: candidates are: int foo<int, int>(int)
test.cpp:11: int foo<int>(int)
test.cpp:19: warning: control reaches end of non-void function `main()'
--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.