This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


2487. Type dependence of function-style cast to incomplete array type

Section: 13.8.3.3  [temp.dep.expr]     Status: drafting     Submitter: Richard Smith     Date: 2021-03-12

Consider:

  using T = int[];
  using U = int[2];
  template<auto M, int ...N> void f() {
    auto &&arr1 = T(N...);
    auto &&arr2 = T{N...};
    auto &&arr3 = U(M, M);
    auto &&arr4 = U{M, M};
  };

I think here T(N...) is not type-dependent, per 13.8.3.3 [temp.dep.expr] paragraph 3, but should be. (I think T{N...} is type-dependent.) Conversely, I think U{M, M} is type-dependent, per 13.8.3.3 [temp.dep.expr] paragraph 6, but should not be. (U(M, M) is not type-dependent.)

I think we should say that

are type-dependent if the type specifier names a dependent type, or if it names an array of unknown bound and the braced-init-list or expression-list is type-dependent.

(I think we could be a little more precise than that in the case where there is no top-level pack expansion: T{M, M} needs to be type-dependent for a general array of unknown bound T due to brace elision, but not in the case where the array element type is a scalar type. And T(M, M) does not need to be type-dependent because direct aggregate initialization can't perform brace elision. But I think the simpler rule is probably good enough.)

Notes from the August, 2021 teleconference:

CWG agreed with the suggested change. There was some support for the “more precise” approach mentioned in the description.