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

2023-12-02


2746. Checking of default template arguments

Section: 13.8.1  [temp.res.general]     Status: open     Submitter: Shafik Yaghmour     Date: 2023-06-07

Consider:

  static int x = 1;
  template<auto y = x> void f() {}

Is the definition of f well-formed? Since x is not a constant expression, any use of the default template argument is ill-formed, but for example f<5>() does not actually use it.

Are implementations allowed or required to reject this situation, even if the template is never instantiated? If the default template argument is dependent, checking may need to be deferred to instantiations in any case.

Possible resolution:

Change in 13.8.1 [temp.res.general] paragraph 6 as follows:

The validity of a template may be checked prior to any instantiation. [Note : ... —end note]

The program is ill-formed, no diagnostic required, if: