[LifetimeSafety] Support C compound literals
Open
clang:temporal-safety
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
LifetimeSafety does not fully model C compound literals yet.
Minimal repro:
```c
int *bad(void) {
int *p = &(int){12};
return p; // should warn
}
```
https://godbolt.org/z/6oPvfr9bn
In C, compound literal has automatic storage duration, so this should behave roughly like returning the address of an unnamed local variable.
Expected: warn that the returned pointer refers to storage that does not live long enough.
This should remain OK however:
```c
int ok(void) {
int *p = &(int){12};
*p = 100;
return *p;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.