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: unassig...@gcc.gnu.org
        ReportedBy: l...@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 via email to