public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7704: template match difference on function pointer template args
@ 2002-09-13 15:03 nathan
  0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2002-09-13 15:03 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, leick.robinson, nobody

Synopsis: template match difference on function pointer template args

State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Fri Sep 13 15:03:10 2002
State-Changed-Why:
    3.x is correct. T (*) (...), will match varadic functions
    NOT functions with arbitrary argument lists (for that
    you'd need a nonexistant varadic template parameter),

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7704


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

* c++/7704: template match difference on function pointer template args
@ 2002-08-23 10:26 leick.robinson
  0 siblings, 0 replies; 2+ messages in thread
From: leick.robinson @ 2002-08-23 10:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7704
>Category:       c++
>Synopsis:       template match difference on function pointer template args
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 23 09:36:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     leick.robinson@motorola.com
>Release:        gcc 2.95.2 or gcc 3.0.4
>Organization:
>Environment:
SUNW,Ultra-60
SunOS 5.8
>Description:
It's not clear whether the bug is in gcc 2.95.2 or 3.0.4.

There's a difference in the way these releases match 
template arguments to the corresponding (partial) template 
specialization.

In the code below, gcc 2.95.2 matches the function pointer
argument ( A<void (*) ()> ) to the last specialization
( class A<retval (*) (...)> ).

On the other hand, gcc 3.0.4 matches it to the specialization
for pointers ( A<U*> ).

Which is the correct behavior?
>How-To-Repeat:
#include <iostream>
using namespace std;

template <class T>
class A {
public:
   static void foo()
   {
      cout << "Default A" << endl;
   }
};

// Template specialization for a pointer
template <class U>
class A<U*> {
public:
   static void foo()
   {
      cout << "A for pointers" << endl;
   }
};

// Template specialization for function pointers (?)
template <class retval>
class A<retval (*) (...)> {
public:
   static void foo()
   {
      cout << "A for function pointers" << endl;
   };
};

int main()
{
   A<int>::foo();

   A<int*>::foo();

   A<void (*) ()>::foo();
}

// g++ 2.95.2 produces:
//
// Default A
// A for pointers
// A for function pointers
//
// g++ 3.0.4 produces:
//
// Default A
// A for pointers
// A for pointers
//
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2002-09-13 22:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-13 15:03 c++/7704: template match difference on function pointer template args nathan
  -- strict thread matches above, loose matches on Subject: below --
2002-08-23 10:26 leick.robinson

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).