public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51613] New: Ambiguous function template instantiations as template argument are not rejected
@ 2011-12-18 22:18 pkmx.tw at gmail dot com
  2011-12-29  7:38 ` [Bug c++/51613] [4.4/4.5/4.6/4.7 Regression] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: pkmx.tw at gmail dot com @ 2011-12-18 22:18 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-11 20:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-18 22:18 [Bug c++/51613] New: Ambiguous function template instantiations as template argument are not rejected pkmx.tw at gmail dot com
2011-12-29  7:38 ` [Bug c++/51613] [4.4/4.5/4.6/4.7 Regression] " pinskia at gcc dot gnu.org
2012-01-04 13:47 ` rguenth at gcc dot gnu.org
2012-01-11 13:50 ` jason at gcc dot gnu.org
2012-01-11 16:47 ` jason at gcc dot gnu.org
2012-01-11 20:40 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).