Issue 163602
Summary Find a solution to annotate functions like std::make_unique
Labels clang:temporal-safety
Assignees
Reporter usx95
    ```cpp
#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();
}
```

https://godbolt.org/z/ozo5q4Wx1
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to