[Bug c++/82773] New: Function-type non-type template parameter not accepted

support at neoee dot net gcc-bugzilla@gcc.gnu.org
Mon Oct 30 19:44:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82773

            Bug ID: 82773
           Summary: Function-type non-type template parameter not accepted
           Product: gcc
           Version: 7.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: support at neoee dot net
  Target Milestone: ---

When instantiating a C++ function template passing a function-type non-typed
template parameter (e.g. one of type void(int)), the compiler will reject
compilation with the message "error: 'void(int)' is not a valid type for a
template non-type parameter". As far as I can tell, this should flawlessly
work.

void foobar(int);

// decltype(foo) should be evaluating to void (*)(int), acc. to §14.1.8
[temp.param]
template <typename T, T foo> 
void bar();

template <auto foo>
void baz();

template <typename T>
struct E {
    template <T f>
    void bar();
};

int main() {
    baz<foobar>(); // ok
    E<void (int)>{ }.bar<foobar>(); // ok
    bar<void (int), foobar>(); // not ok
}


More information about the Gcc-bugs mailing list