https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118624
Bug ID: 118624
Summary: in-class template declaration failed to match
out-class impl
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: shyeyian at petalmail dot com
Target Milestone: ---
struct test
{
template < int x >
int fun()
requires (x == 1);
int x();
};
template < int x >
int test::fun()
requires (x == 1)
{
return 42;
}
int main ( )
{
}
==========================
Compilation failed (with g++ --version == 14.2)
main.cpp:12:16: error: invalid use of member 'test:()' (did you forget the '&'
?)
12 | requires ( x == 1 )
| ^
main.cpp:11:5: error: no declaration matches 'int test::fun() requires
<erroneous-expression>'
11 | int test::fun()
| ^~~~
main.cpp:4:9: note: candidate is: 'template<int x> int test::fun() requires x
== 1'
4 | int fun()
| ^~~
main.cpp:1:8: note: 'struct test' defined here
1 | struct test
| ^~~~
On clang++ it works good.