[clang] [analyzer] Fix false positive for stack-addr leak on simple param ptr (PR #107003)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 2 22:28:51 PDT 2024
================
@@ -791,3 +791,58 @@ void global_ptr_to_ptr() {
*global_pp = nullptr;
}
} // namespace leaking_via_indirect_global_invalidated
+
+namespace not_leaking_via_simple_ptr {
+void simple_ptr(const char *p) {
+ char tmp;
+ p = &tmp; // no-warning
+}
+
+void ref_ptr(const char *&p) {
+ char tmp;
+ p = &tmp; // expected-warning{{variable 'tmp' is still referred to by the caller variable 'p'}}
+}
+
+struct S {
+ const char *p;
----------------
steakhal wrote:
How about taking one struct by value holding encapsulating a reference member refering to a stack variable?
https://github.com/llvm/llvm-project/pull/107003
More information about the cfe-commits
mailing list