Skip to content

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

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).

Activity

  1. added this to the 2023-telecon milestone on Jan 25, 2023
  2. jensmaurer commented on Mar 14, 2024

    @jensmaurer
    Member

    The links to the old e-mail thread seem to be wrong, above. Use this one: https://lists.isocpp.org/ext/2020/05/13752.php instead. And Andrzej's announcement of his paper is here: https://lists.isocpp.org/ext/2021/01/15815.php

    This issue would be resolved by P2285 Are default function arguments in the immediate context? #976

  3. removed this from the 2024-telecon milestone on Dec 18, 2024
  4. hanickadot commented on May 20, 2026

    @hanickadot
    Collaborator

    @jensmaurer this was resolved with P4149 #2681 (approved in Croydon at plenary)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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