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

2022-07-01


393. Pointer to array of unknown bound in template argument list in parameter

Section: 9.3.4.6  [dcl.fct]     Status: CD4     Submitter: Mark Mitchell     Date: 12 Dec 2002

[Moved to DR at the November, 2014 meeting.]

EDG rejects this code:

  template <typename T>
  struct S {};

  void f (S<int (*)[]>);
G++ accepts it.

This is another case where the standard isn't very clear:

The language from 9.3.4.6 [dcl.fct] is:

If the type of a parameter includes a type of the form "pointer to array of unknown bound of T" or "reference to array of unknown bound of T," the program is ill-formed.
Since "includes a type" is not a term defined in the standard, we're left to guess what this means. (It would be better if this were a recursive definition, the way a type theoretician would do it: )

Notes from April 2003 meeting:

We agreed that the example should be allowed.

Additional note (January, 2013):

Additional discussion of this issue has arisen . For example, the following is permissible:

  T (*p) [] = (U(*)[])0;

but the following is not:

  template<class T>
  void sp_assert_convertible( T* ) {}

  sp_assert_convertible<T[]>( (U(*)[])0 );

Proposed resolution (February, 2014):

Change 9.3.4.6 [dcl.fct] paragraph 8 as follows, including deleting the footnote:

If the type of a parameter includes a type of the form “pointer to array of unknown bound of T” or “reference to array of unknown bound of T,” the program is ill-formed.101 Functions shall not have a return type of type array or function, although...