| Issue |
56676
|
| Summary |
-Wreturn-stack-address should handle clang::musttail calls
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
efriedma-quic
|
As noted at https://github.com/llvm/llvm-project/issues/56435#issuecomment-1192823619 and https://github.com/llvm/llvm-project/issues/56435#issuecomment-1179143671, there's a potential trap with musttail calls: all local variables are freed by the call. So if you pass a pointer to a local variable, and try to use it, it's a use-after-free. We should warn if someone writes something like the following:
```
int bar(int* x);
int foo(int*) {
int local = 11;
[[clang::musttail]] return bar(&local);
}
```
This is very similar to the existing -Wreturn-stack-address, so it probably makes sense to put it into the existing warning group.
(While we're looking at this, it might also be nice to update the documentation for clang::musttail.)
CC @foonathan @haberman
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs