You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lint for returning a pointer to stack memory associated with a local variable #134215
A warning that this pointer is referencing a local variable and is going to be dangling immediately. E.g.
error: returning a pointer to stack memory associated with a local variable
--> <source>:12:5
|
LL| &x
| ^^
Rationale and extra context
This code is very unlikely to be correct, which is exactly why a warning should be emitted. This would be similar to Clang's -Wreturn-stack-address warning.
In case of returning a reference, rustc would catch this and emit a compiler error. While it is fine to create such a pointer, it is very unlikely that the code should be written that way.
If this becomes a Warn lint it will start warning immediately and potentially break users that configured warnings as errors. So maybe this should be Allow for the beginning?
Activity
Auto merge of rust-lang#134218 - 1c3t3a:stack-memory-warning, r=<try>