Skip to content

Support use of clang::lifetime_capture_by in constructors #117680

@usx95

Description

@usx95

https://godbolt.org/z/KqM3znMhT

struct S{
    S(const int& s [[clang::lifetimebound]]);
};
struct T{
    T(const int& t [[clang::lifetime_capture_by(this)]]);
};

void foo() {
    S s(1); // Error. Good.
    T t(1); // No diagnostic here. Bad.
}

Metadata

Metadata

Assignees

Labels

clang:memory-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions