public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luto at mit dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/50372] New: c++11: pointers to static functions should be valid template parameters
Date: Tue, 13 Sep 2011 03:13:00 -0000	[thread overview]
Message-ID: <bug-50372-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50372

             Bug #: 50372
           Summary: c++11: pointers to static functions should be valid
                    template parameters
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: luto@mit.edu


Created attachment 25253
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25253
Test case

In n3242 [temp.arg.nontype]:

A template-argument for a non-type, non-template template-parameter shall be
one of:
...
 - a constant expression (5.19) that designates the address of an object with
static storage duration and external or internal linkage or a function with
external *or internal* linkage, ...  [emphasis added]

Nonetheless, the attached test case fails to compile with:

foo.cc: In function ‘void test()’:
foo.cc:8:21: error: ‘static_func’ is not a valid template argument for type
‘void (*)()’ because function ‘void static_func()’ has not external linkage
foo.cc:8:21: error: no matching function for call to ‘foo()’
foo.cc:8:21: note: candidate is:
foo.cc:2:6: note: template<void (* fptr)()> void foo()
foo.cc:2:6: note:   substitution of deduced template arguments resulted in
errors seen above

even with -std=gnu++0x.  Tested on 4.6.0 and trunk r178795.

AFAICT the error is correct in c++98 mode.


             reply	other threads:[~2011-09-13  0:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-13  3:13 luto at mit dot edu [this message]
2011-11-11  6:07 ` [Bug c++/50372] [C++0x] " jason at gcc dot gnu.org
2011-11-13 10:09 ` jason at gcc dot gnu.org

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=bug-50372-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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: link
Be 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).