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


2043. Generalized template arguments and array-to-pointer decay

Section: 13.4.3  [temp.arg.nontype]     Status: drafting     Submitter: Richard Smith     Date: 2014-11-13

According to 13.4.3 [temp.arg.nontype] paragraph 1 (newly revised by the adoption of paper N4268),

For a non-type template-parameter of reference or pointer type, the value of the constant expression shall not refer to (or for a pointer type, shall not be the address of):

This change breaks an example like

   template<int *p> struct X {};
   int arr[32];
   X<arr> x;

because the array-to-pointer decay produces a pointer to the first element, which is a subobject.

Suggested resolution:

Change the referenced bullet to read:

Note that this resolution also allows an example like

    template<char &p> struct S { };
    char arr[2];
    S<arr[0]> s_arr;

which may not be exactly what we want.

See also issue 2401.