CWG Issue 2715 (original) (raw)

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

2025-11-07


2715. "calling function" for parameter initialization may not exist

Section: 7.6.1.3 [expr.call]Status: CD7Submitter: Brian BiDate: 2023-04-02

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

Subclause 7.6.1.3 [expr.call] paragraph 6 specifies:

... The initialization and destruction of each parameter occurs within the context of the calling function. [_Example 2:_ The access of the constructor, conversion functions or destructor is checked at the point of call in the calling function. If a constructor or destructor for a function parameter throws an exception, the search for a handler starts in the calling function; in particular, if the function called has a _function-try-block_ (14.1 [except.pre]) with a handler that can handle the exception, this handler is not considered. —_end example_]

However, there is no calling function in the case where a function call appears in the initializer of a namespace-scope variable. Likewise, some constant expressions appearing in a type-id do not have calling functions, either. For example:

class C { private: constexpr int C(int) {} friend void foo(int (*a)[1]) noexcept; };

constexpr int bar(C) { return 1; }

void foo(int (&a)[bar(1)]) noexcept(bar(2) > 0); // presumably OK because of friendship

Proposed resolution (approved by CWG 2023-04-28):

Change in 7.6.1.3 [expr.call] paragraph 6 as follows:

... The initialization and destruction of each parameter occurs within the context of the calling function full-expression (6.10.1 [intro.execution]) where the function call appears. [_Example 2:_ The access(11.8.1 [class.access.general]) of the constructor, conversion functions, or destructor is checked at the point of call in the calling function. If a constructor or destructor for a function parameter throws an exception, the search for a handler starts in the calling function; in particular, if the function called has a any function-try-block(14.1 [except.pre]) of the called function with a handler that can handle the exception, this handler is not considered. —_end example_]