Skip to content

[clang] Clang must diagnose the use of [[lifetimebound]] annotation in void-returning functions #107556

@usx95

Description

@usx95

https://godbolt.org/z/rcPnrWrr7

#include <string>
struct S {
    void setS(const std::string& s [[clang::lifetimebound]]) { this->s = &s; }
    const std::string* s;
};

void foo() {
    S s;
    s.setS(std::string());
}

Lifetime analysis is currently not defined for parameters annotated with [[lifetimebound]] in void-returning function.
Current analysis only enforces that the annotated parameter outlives the return value. With no return value, this analysis is silently disabled.

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"clang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions