public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: leick.robinson@motorola.com To: gcc-gnats@gcc.gnu.org Subject: c++/7704: template match difference on function pointer template args Date: Fri, 23 Aug 2002 10:26:00 -0000 [thread overview] Message-ID: <20020823162932.29173.qmail@sources.redhat.com> (raw) >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:
next reply other threads:[~2002-08-23 16:36 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-08-23 10:26 leick.robinson [this message] 2002-09-13 15:03 nathan
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020823162932.29173.qmail@sources.redhat.com \ --to=leick.robinson@motorola.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).