-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[clang] Clang must diagnose the use of [[lifetimebound]] annotation in void-returning functions #107556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-clang-frontend Author: Utkarsh Saxena (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 |
This is at least known about: llvm-project/clang/test/SemaCXX/attr-lifetimebound.cpp Lines 4 to 5 in 775f7f1
However, what about dependent void: template<typename T>
std::add_lvalue_reference_t<const T> get_value(cached_function<T>& f [[clang::lifetimebound]]) {
if (!f.has_value()) f.call_and_cache();
return f.cached_value();
} For |
Can I pick this up? Can I have some more pointers what need to be done for this issue? |
…n a function implicit object parameter while the function returns void Fixes: llvm#107556
…n a function implicit object parameter while the function returns void Fixes: llvm#107556
…n a function parameter while the function returns void (llvm#113460) Fixes: llvm#107556
https://godbolt.org/z/rcPnrWrr7
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.
The text was updated successfully, but these errors were encountered: