[clang] [clang] Don't infer lifetime_capture-by for reference of raw pointer types. (PR #122240)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 9 07:26:40 PST 2025


================
@@ -406,7 +406,7 @@ void use() {
   strings.insert(strings.begin(), std::string());
 
   std::vector<const std::string*> pointers;
-  pointers.push_back(getLifetimeBoundPointer(std::string())); // expected-warning {{object whose reference is captured by 'pointers' will be destroyed at the end of the full-expression}}
+  pointers.push_back(getLifetimeBoundPointer(std::string()));
----------------
hokein wrote:

I completely agree that it would be ideal to restore the diagnostic without introducing false positives. However, I currently don’t have a simple solution for how to achieve this.

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


More information about the cfe-commits mailing list