================
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety 
-Wno-gnu-statement-expression -verify %s
+
+// A GNU statement expression (`({ ...; e; })`) yields the value of its final
+// expression `e`. Its origins forward to `e`, and the value is used at the
+// statement expression's program point (after the body's locals expire), so a
+// borrow `e` carries is tracked: a borrow of a body-local is a 
use-after-scope,
+// and a borrow forwarded from an outer object propagates.
+
+void use(int *p);
+
+// A borrow of a statement-expression-local escaping via the value.
+void borrow_of_local() {
----------------
usx95 wrote:

test suggestion to use `std::string`
```
std::string_view view = ({ std::string x = "7"; x; });
use(view);
```

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

Reply via email to