llvm / llvm/llvm-project

[LifetimeSafety] Suggest annotation for returning object with a pointer

Open
#180,517 4 comments 0 reactions 0 assignees View on GitHub
clang:temporal-safety false-negative
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c++
struct A {
int* ptr;
};
A Foo(int* ptr) {
return {ptr};
}
```

Expected the following warning when using `-Wlifetime-safety -Wlifetime-safety-suggestions`: `parameter ... should be marked [[clang::lifetimebound]]`. Actual result on ToT - no warnings.

Contributor guide

Open the contributing guide

Research direction

Start with the inline C++ reproducer and run it on ToT using -Wlifetime-safety -Wlifetime-safety-suggestions. Trace the lifetime-safety diagnostic path for functions returning an object containing a pointer; done means the parameter is suggested for [[clang::lifetimebound]] and the existing behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.