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

             Bug #: 53782
           Summary: Pointer to static function member expression rejected
                    in class template
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: daniel.krueg...@googlemail.com


gcc 4.8.0 20120610 (experimental) compiled with -Wall (also tested with
-pedantic and -std=c++11) rejects the following code:

//-----
template<void(*)()>
struct func_ptr{};

template<class T>
struct S {
  static void invariants() {}
  typedef func_ptr<&invariants> enforce_evaluation;  // Line 7
};

S<int> s;
//-----

"7|error: template argument 1 is invalid"

I'm reporting this, because there is only a very small set of valid forms
accepted by all compilers I have to support. The form used above is valid
according to the language rules and accepted by all other compilers I tested
(Comeau, VC 11 Beta, Clang 3.0) but not by gcc. A current workaround is to
write "&S::invariants" instead, but it seems a pity that the "obvious" syntax
doesn't work.

Reply via email to