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

2024-07-24


2178. Substitution of dependent template arguments in default template arguments

Section: 13.2  [temp.param]     Status: NAD     Submitter: Richard Smith     Date: 2015-10-06

Consider the following example:

   template<typename T, T V, int n = sizeof(V)> using X = int[n];
   template<typename T> void f(X<T, 0>*) {}
   void g() { f<char>(0); }

Current implementations get confused here because they substitute V=0 into the default argument of X before knowing the type T and end up with f having type void (int (*)[sizeof(0)]), that is, the array bound does not depend on T. It's not clear what should happen here.

Rationale (March, 2016):

There is no problem with the specification, only with the implementations; the default argument for n is dependent because V has a dependent type.