https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127355
Bug ID: 127355
Summary: reflection: cannot extract pointer to static member
function template within class template
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ivan.lazaric.gcc at gmail dot com
Target Milestone: ---
```cpp
#include <meta>
template<typename T>
struct S {
template<typename = void>
static consteval T foo() { return 42; }
static consteval T bar() {
return extract<T(*)()>(substitute(^^foo, {}))();
}
};
static_assert(S<int>::bar() == 42);
```
Flags: "-std=c++26 -freflection"
Outcome:
```
bug2.cpp:13:29: error: non-constant condition for static assertion
13 | static_assert(S<int>::bar() == 42);
| ~~~~~~~~~~~~~~^~~~~
bug2.cpp:13:29: error: uncaught exception of type 'std::meta::exception';
'what()': 'value cannot be extracted'
```
Godbolt: https://godbolt.org/z/n53qq6o73
Can be worked around by moving the static member
function (template) out of class,
make it a free function (template).