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

2024-11-11


2760. Defaulted constructor that is an immediate function

Section: 7.7  [expr.const]     Status: DRWP     Submitter: Corentin Jabot     Date: 2023-07-08

[Accepted as a DR at the November, 2023 meeting.]

Consider:

  consteval int f(int);
  struct S {
   int x = f(0);
   S() = default;
  };

  int main() {
    S s;     // OK?
  }

Is S an immediate function?

The relevant specification is in 7.7 [expr.const] paragraph 18:

An immediate function is a function or constructor that is

Suggested resolution [SUPERSEDED]:

Change in 7.7 [expr.const] paragraph 18 as follows:

An immediate function is a function or constructor that is

Proposed resolution (approved by CWG 2023-08-25):

  1. Change in 7.7 [expr.const] paragraph 18 as follows:

    An immediate function is a function or constructor that is
    • declared with the consteval specifier, or
    • an immediate-escalating function F whose function body contains an immediate-escalating expression E such that E's innermost enclosing non-block scope is F's function parameter scope. [ Note: Default member initializers used to initialize a base or member subobject (11.9.3 [class.base.init]) are considered to be part of the function body (9.5.1 [dcl.fct.def.general]). -- end note ]
  2. Change in 9.5.1 [dcl.fct.def.general] paragraph 1 as follows:

    Any informal reference to the body of a function should be interpreted as a reference to the non-terminal function-body, including, for a constructor, default member initializers or default initialization used to initialize a base or member subobject in the absence of a mem-initializer-id (11.9.3 [class.base.init]).