[clang] [clang] Don't warn if the capturing object is also temporary. (PR #117733)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 27 19:48:20 PST 2024


usx95 wrote:

I considered this during implementation. This is a little controversial.

It is possible that the temporary capturing object uses the captured entity in its destructor. In principle, we can always detect the order of destructions of the temporaries and choose to suppress cases when captured temporary outlives capturing temporary. But it would be a very confusing behaviour for the user, eg: switching order of params suppresses the warning.

I would be in favour of not doing this and always diagnosing this for simplicity until we see a strong need or practical false positives. WDYT ? 


https://github.com/llvm/llvm-project/pull/117733


More information about the cfe-commits mailing list