================
@@ -396,6 +396,131 @@ void loan_from_previous_iteration(MyObj safe, bool 
condition) {
   }             // expected-note {{destroyed here}}
 }
 
+//===----------------------------------------------------------------------===//
+// Basic Definite Use-After-Return (Return-Stack-Address) (-W...permissive)
+// These are cases where the pointer is guaranteed to be dangling at the use 
site.
+//===----------------------------------------------------------------------===//
+
+MyObj* simple_return_stack_address(){
+  MyObj s;      
+  MyObj* p = &s; // expected-warning {{returning reference to stack allocated 
object}}
+  return p;      // expected-note {{returned here}}
+}
+
+MyObj* conditional_assign_unconditional_return(MyObj safe, bool c){
----------------
usx95 wrote:

> `MyObj safe`

This is a param which lives on stack. Returning this is not safe. You can 
change this to a reference `const MyObj& safe`. Same for all the added tests.
This should have error'ed if we had the correct expire facts.

https://github.com/llvm/llvm-project/pull/165370
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to