[Bug c++/17754] New: [3.4 regression] Static member function not accepted as non-type template argument

benh at bwsint dot com gcc-bugzilla@gcc.gnu.org
Thu Sep 30 17:59:00 GMT 2004


g++ 3.4.1 doesn't accept a static member function as the argument for a non-type
template parameter of the appropriate function type. For example, given:

<code>
template<void (*)()> void tfunc();

struct foo
{
    static void bar();
};

void foo::bar()
{
    tfunc<bar>();
}
</code>

it says:

<error>
In static member function `static void foo::bar()':
error: `static void foo::bar()' cannot appear in a constant-expression
error: template argument 1 is invalid
error: no matching function for call to `tfunc()'
</error>

g++ 3.3.4 accepts the code.

-- 
           Summary: [3.4 regression] Static member function not accepted as
                    non-type template argument
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: benh at bwsint dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu


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



More information about the Gcc-bugs mailing list