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


2296. Are default argument instantiation failures in the “immediate context”?

Section: 13.10.3  [temp.deduct]     Status: open     Submitter: Jason Merrill     Date: 2016-06-25     Liaison: EWG

Consider the following example (taken from issue 3 of paper P0348R0):

  template <typename U> void fun(U u = U());

  struct X {
    X(int) {}

  template <class T> decltype(fun<T>()) g(int) { }

  template<> void g(long) { }

  int main() { g<X>(0); }

When is the substitution into the return type done? The current specification makes this example ill-formed because the failure to instantiate the default argument in the decltype operand is not in the immediate context of the substitution, although a plausible argument for making this a SFINAE case can be made.

Notes from the June, 2016 meeting:

CWG decided to refer this question to EWG for their consideration.

EWG 2022-11-11

This is tracked in github issue cplusplus/papers#1377.