Title
Invalid types in the parameter-declaration-clause of a requires-expression
Status
open
Section
7.5.7.1 [expr.prim.req.general]
Submitter
Barry Revzin

Created on 2022-04-07.00:00:00 last changed 1 month ago

Messages

Date: 2022-04-13.07:01:41

Suggested resolution:

Change in 7.5.7.1 [expr.prim.req.general] paragraph 5:

The substitution of template arguments into a requires-expression may result in the formation of invalid types or expressions in its parameter-declaration-clause (if any) or its requirements or the violation of the semantic constraints of those requirements. In such cases, ...
Date: 2022-04-07.00:00:00

Consider:

  template <typename T>
  concept C = requires (typename T::type x) {
    x + 1;
  };

  static_assert(!C<int>);

All implementations accept this translation unit. However, the rule in 7.5.7.1 [expr.prim.req.general] paragraph 5 does not cover the parameter-declaration-clause::

The substitution of template arguments into a requires-expression may result in the formation of invalid types or expressions in its requirements or the violation of the semantic constraints of those requirements. In such cases, the requires-expression evaluates to false; it does not cause the program to be ill-formed. The substitution and semantic constraint checking proceeds in lexical order and stops when a condition that determines the result of the requires-expression is encountered. If substitution (if any) and semantic constraint checking succeed, the requires-expression evaluates to true.
History
Date User Action Args
2022-04-13 07:01:41adminsetmessages: + msg6793
2022-04-07 00:00:00admincreate