-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Open
Labels
clang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)
Description
#include <iostream>
#include <memory>
struct A {
std::string_view data;
A(const std::string& a [[clang::lifetimebound]]) : data(a) {}
std::string_view getData() { return data; }
};
std::unique_ptr<A> bar() {
std::string on_stack = "I live on stack";
std::unique_ptr<A> obj = std::make_unique<A>(on_stack);
return obj; // return stack address of locak 'on_stack'
}
int main() {
std::unique_ptr<A> obj = bar();
std::cout << obj->getData();
}
Metadata
Metadata
Assignees
Labels
clang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)
Type
Projects
Status
No status