This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51613] New: Ambiguous function template instantiations as template argument are not rejected
- From: "pkmx.tw at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 18 Dec 2011 22:15:12 +0000
- Subject: [Bug c++/51613] New: Ambiguous function template instantiations as template argument are not rejected
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51613
Bug #: 51613
Summary: Ambiguous function template instantiations as template
argument are not rejected
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: pkmx.tw@gmail.com
In the book "C++ Templates - The Complete Guide" section 8.3, the following
code snippet is given:
template<typename F, typename T>
void apply(F f, T t)
{
f(t);
}
template<typename T>
void multi(T)
{
}
template<typename T>
void multi(T*)
{
}
int main()
{
apply(&multi<int>, 7);
return 0;
}
My understanding is that &multi<int> here instantiates two functions of types
void (*)(int) and void (*)(int*) with no ways to disambiguate and therefore F
cannot be deducted. However, gcc currently deducts F as void (*)(int) and
ultimately calls multi(int). This is the same case for gcc 4.4.3, gcc 4.6.2,
gcc 4.7.0 20111112 snapshot and probably other versions.