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: unassig...@gcc.gnu.org
        ReportedBy: pkmx...@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.

Reply via email to