[Bug c++/107439] New: use of static member function in requires-expression depends on declaration order
jwjagersma at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Oct 27 16:22:19 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107439
Bug ID: 107439
Summary: use of static member function in requires-expression
depends on declaration order
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jwjagersma at gmail dot com
Target Milestone: ---
The following example fails to compile, as g++ complains that a declaration of
'check' is not available. Reordering it so that 'check' is declared before
its use in the requires-expression makes it work. This seems inconsistent, as
member functions are normally expected to be usable anywhere within the class
definition.
$ cat requires-memfn.cpp
struct A
{
template<typename T> requires (check<T>())
auto func(T) { }
template<typename T>
static consteval bool check() { return true; }
};
$ g++ -std=c++20 requires-memfn.cpp
requires-memfn.cpp:3:34: error: there are no arguments to ‘check’ that depend
on a template parameter, so a declaration of ‘check’
must be available [-fpermissive]
3 | template<typename T> requires (check<T>())
| ^~~~~~~~
requires-memfn.cpp:3:34: note: (if you use ‘-fpermissive’, G++ will accept
your code, but allowing the use of an undeclared name is deprecated)
More information about the Gcc-bugs
mailing list