-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Closed
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Description
As noted at #56435 (comment) and #56435 (comment), 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)
foonathan and madebr
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer