This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See for the official list.


2770. Trailing requires-clause can refer to function parameters before they are substituted into

Section:  [temp.deduct.general]     Status: open     Submitter: Richard Smith     Date: 2023-07-14

After the application of issue 2369, satisfaction for a trailing requires-clause is checked prior to substitution into the function type. Subclause [temp.deduct.general] paragraph 5 specifies:

If the function template has associated constraints (13.5.3 [temp.constr.decl]), those constraints are checked for satisfaction (13.5.2 [temp.constr.constr]). ... If type deduction has not yet failed, then all uses of template parameters in the function type are replaced with the corresponding deduced or default argument values.

However, the associated constraints can refer to parameters, thus substitution into the parameter types must have been already done at the time of checking. Consider:

  template<typename T> void f(T t) requires (sizeof(t) == 5) {}

Suggested resolution:

Function parameters should be instantiated when they are needed by a satisfaction check of an atomic constraint or (recursively) by another function parameter.