Description
Full name of submitter: Brian Bi
Reference (section label): [expr.call]
Issue description: [expr.call]/6 states: "[...] The initialization and destruction of each parameter occurs within the context of the calling function." However, a function call that is a subexpression of an init-declarator for a non-local variable does not have a calling function, and some expressions that are evaluated during translation do not have calling functions:
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
Example 2 suggests that the purpose of this sentence is to clarify access control and exception handling. Are there any other language concepts that care about whether the context is that of the caller or the callee?
Suggested resolution:
Edit [expr.call]/6:
[...] It is implementation-defined whether the lifetime of a parameter ends when the function in which it is defined returns or at the end of the enclosing full-expression. For purposes of access control ([class.access.general]), t
The initialization and destruction of each parameter occurs within the context of thecalling functionfull-expression to which it belongs ([intro.execution]).[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—end example]
starts in the calling function; in particular, if the function called has a function-try-block (14.1) with a handler that
can handle the exception, this handler is not considered.[Note -?-: As specified in [except.throw], if a constructor or destructor for a function parameter throws an exception, the search for a handler starts in the calling function, if any; in particular, if the function called has a function-try-block ([except.pre]) with a handler that can handle the exception, this handler is not considered. —end note]