llvm / llvm/llvm-project

Find a solution to annotate forwarding functions like std::make_unique

Open
#163,602 6 comments 0 reactions 0 assignees View on GitHub
clang:temporal-safety
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```cpp
#include
#include

struct A {
std::string_view data;
A(const std::string& a [[clang::lifetimebound]]) : data(a) {}
std::string_view getData() { return data; }
};

std::unique_ptr bar() {
std::string on_stack = "I live on stack";
std::unique_ptr
obj = std::make_unique(on_stack);
return obj; // return stack address of locak 'on_stack'
}

int main() {
std::unique_ptr
obj = bar();
std::cout << obj->getData();
}
```

https://godbolt.org/z/ozo5q4Wx1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.