[clang] [clang] Diagnose dangling issues for the "Container<GSLPointer>" case. (PR #107213)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 4 07:49:49 PDT 2024


================
@@ -499,3 +518,28 @@ std::string_view test2(int i, std::optional<std::string_view> a) {
   return std::move(a.value());
 }
 }
+
+namespace GH100526 {
+void test() {
+  std::vector<std::string_view> t1 = {std::string()}; // expected-warning {{object backing the pointer will be destroyed at the end}}
----------------
usx95 wrote:

Can you try adding more than one args to init list for `std::vector`.
Eg: `std::vector<std::string_view> s = {std::string_view(),  std::string()}`

Does it work atm ?

https://github.com/llvm/llvm-project/pull/107213


More information about the cfe-commits mailing list