https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100374
Bug ID: 100374
Summary: Type-constraints of member function templates should
not be substituted into during implicit instantiation
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rs2740 at gmail dot com
Target Milestone: ---
template<class T, class U>
concept C = true;
template <class T>
struct Foo
{
template <C<typename T::value_type> U>
void bar()
{
}
};
Foo<float> f;
GCC trunk with -std=c++20 produces:
<source>: In instantiation of 'struct Foo<float>':
<source>:13:12: required from here
<source>:8:8: error: 'float' is not a class, struct, or union type
8 | void bar()
| ^~~
[temp.inst]/17 says that type-constraints like C<typename T::value_type> should
not be substituted into during the implicit instantiation of the declaration of
Foo<float>::bar:
The type-constraints and requires-clause of a template specialization or member
function are not instantiated along with the specialization or function itself,
even for a member function of a local class; substitution into the atomic
constraints formed from them is instead performed as specified in
[temp.constr.decl] and [temp.constr.atomic] when determining whether the
constraints are satisfied or as specified in [temp.constr.decl] when comparing
declarations.