Skip to content

lifetimebound on more functions, including container methods #62390

Open
@higher-performance

Description

@higher-performance

A suggestion that I wanted to relay:

In the spirit of #59900 and #60020, how about adding [[clang::lifetimebound]] to other functions as well?
Containers in particular seem to have many methods that could benefit from this attribute, including back(), begin(), data(), emplace_back(), find(), insert(), operator[], etc., since all of their outputs require the container to be alive for validity.
Beyond containers, I think this could be similarly used for functions such as std::unique_ptr::get(), std::variant::get_if(), etc.

Metadata

Metadata

Assignees

Labels

clang:memory-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)enhancementImproving things as opposed to bug fixing, e.g. new or missing featurelibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions