Skip to content

CWG2296 Are default argument instantiation failures in the “immediate context”? #1377

@jfbastien

Description

@jfbastien

Migrating from https://isocpp.org/files/papers/P1018R18.html#issues
CWG2296

Section: 13.10.3 [temp.deduct] Status: extension Submitter: Jason Merrill Date: 2016-06-25
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.

Meeting: (notes 2020-05-07)

The first example under issue 3 of paper P0348R0 should become well-formed.

SF F N A SA

0 1 4 3 6

The second example under issue 3 of paper P0348R0 should become well-formed.

SF F N A SA

1 5 7 3 0

This is an issue. We’d like to see a paper addressing it. It should explore what “Immediate context” means. No objection to unanimous consent.

Daveed / Hubert might entertain writing a paper explaining this.

Ville emailed EWG about this.

JF contacted Andrzej to see if he’s interested in addressing this. Not sure he is.

Meeting 2020-10-28: Tomasz will write a paper which exposes the issue and what he thinks should be done (but not resolving wording itself). Hubert remembers an email about this, will find it and sync with JF.

Meeting 2021-01-14: Andrzej wrote a paper for this (emailed 2021-01-12 to EWG).

Metadata

Metadata

Assignees

No one assigned

    Labels

    EWGEvolutionneeds-revisionPaper needs changes before it can proceed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions