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


2774. Value-dependence of requires-expressions

Section:  [temp.dep.constexpr]     Status: open     Submitter: Christof Meerwald     Date: 2023-07-17


   template<typename T>
   struct A
     static_assert(sizeof(T) == 3);    // #1

   template<bool B>
   struct C
     static_assert(B);                 // #2

   template<typename T, typename U>
   int f(typename C<requires { typename T::type; }>::type, typename A<T>::type, U);

   int i = f<char>(0, 1, 2);

Is the requires-expression value-dependent after substituting the explicit template argument, thus failing at #2 instead of at #1?

Suggested resolution:

  1. Change in [temp.dep.expr] paragraph 4 as follows:

    Expressions of the following forms are never type-dependent (because the type of the expression cannot be dependent):
      noexcept ( expression )
  2. Insert a new paragraph before [temp.dep.constexpr] paragraph 5:

    A requires-expression is value-dependent if it depends on a template parameter.

    An expression of the form &qualified-id where the qualified-id names a dependent member ...

CWG 2023-08-25

The first change has consensus and is progressed via issue 2785; the second change should use an approach of recursive decomposition for requires-expression, similar to other paragraphs in [temp.dep.constexpr]. The implementation divergence is believed to be an independent bug in one implementation.