[PATCH] D139586: [Clang][C++23] Lifetime extension in range-based for loops

Hubert Tong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 20 15:23:27 PDT 2023


hubert.reinterpretcast added a comment.

In D139586#4363725 <https://reviews.llvm.org/D139586#4363725>, @cor3ntin wrote:

> @hubert.reinterpretcast I'll try to look at that but unless I'm mistaken,  the wording excludes function parameters
>
>> The fourth context is when a temporary object **other than a function parameter** object is created in the for-range-initializer of a range-based for statement. If such a temporary object would otherwise be destroyed at the end of the for-range-initializer full-expression, the object persists for the lifetime of the reference initialized by the for-range-initializer.
>
> I think that invalidates some of your examples?

@cor3ntin, the examples I gave were for temporary objects created for binding to a reference (that, in turn, happens to be a function parameter). Those temporary objects are not function parameters.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139586/new/

https://reviews.llvm.org/D139586



More information about the cfe-commits mailing list