================
@@ -112,3 +112,56 @@ void inlined_callee_single_report() {
// expected-note@-1 {{Calling 'deref_param'}}
(void)r;
}
+
+struct MyBuffer {
+ char buffer[8];
+};
+
+void member_subregion_dangling_deref() {
+ const char *p = nullptr;
+ {
+ struct MyBuffer tmp_buffer = {};
+ p = tmp_buffer.buffer;
+ }
+ // expected-note@-1 {{'tmp_buffer.buffer[0]' is destroyed here}}
+ char c = *p;
+ // expected-warning@-1 {{Use of 'tmp_buffer.buffer[0]' after its lifetime
ended}}
+ // expected-note@-2 {{Use of 'tmp_buffer.buffer[0]' after its lifetime
ended}}
+ (void)c;
----------------
steakhal wrote:
An alternative way of phrasing this is `return *p;`
I don't mind this either - I just wanted to share this technique.
https://github.com/llvm/llvm-project/pull/211552
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits