CWG2849 [class.temporary] "temporary object other than a function parameter object" wording is wrong · Issue #490 · cplusplus/CWG (original) (raw)

Full name of submitter: Brian Bi

Reference (section label): [class.temporary]

Issue description: From Stack Overflow.

The wording "temporary object other than a function parameter object" does not make sense since a function parameter object is never a temporary object ([class.temporary]/1). In the example that was added during CWG deliberation in Kona (2022) to illustrate this exception, the parameter of f2 is not a temporary in the first place, so there is no exception. Note that in the special case where the implementation creates an extra temporary under [class.temporary]/3, that temporary is not the same as the function parameter object, and its lifetime is unobservable.

Suggested resolution:

Strike "other than a function parameter object" from [class.temporary]/7.

Insert a new note before Example 2 in [stmt.ranged]:

[ Note: A function parameter object is not a temporary object ([class.temporary]), even if its lifetime ends at the end of the full-expression containing the call ([expr.call]). — end note ]