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
[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
- 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.
Suggested resolution [SUPERSEDED]:
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, or
- an immediate-escalating default constructor of a class which has at least one non-static data member with an immediate-escalating default member initializer.
Proposed resolution (approved by CWG 2023-08-25):
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 ]
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]).