Bug 17754

Summary: [3.4 regression] Static member function not accepted as non-type template argument
Product: gcc Reporter: Ben Hutchings <ben>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: gcc-bugs
Priority: P2 Keywords: rejects-valid
Version: 3.4.1   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target: i486-pc-linux-gnu
Build: Known to work:
Known to fail: Last reconfirmed:

Description Ben Hutchings 2004-09-30 17:59:26 UTC
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.
Comment 1 Andrew Pinski 2004-09-30 18:02:37 UTC
This is already fixed in 3.4.3 see dup bug 17585.

*** This bug has been marked as a duplicate of 17585 ***