================
@@ -1746,3 +1746,32 @@ View test3(std::string a) {
return b; // expected-note {{returned here}}
}
} // namespace non_trivial_views
+
+namespace OwnerArrowOperator {
+void test_optional_arrow() {
+ const char* p;
+ {
+ std::optional<std::string> opt;
+ p = opt->data(); // expected-warning {{object whose reference is captured
does not live long enough}}
+ } // expected-note {{destroyed here}}
+ (void)*p; // expected-note {{later used here}}
+}
+
+void test_optional_arrow_lifetimebound() {
+ View v;
+ {
+ std::optional<MyObj> opt;
+ v = opt->getView(); // expected-warning {{object whose reference is
captured does not live long enough}}
+ } // expected-note {{destroyed here}}
+ v.use(); // expected-note {{later used here}}
+}
+
+void test_unique_ptr_arrow() {
----------------
usx95 wrote:
Oh wow. We were actually missing this https://godbolt.org/z/M87nqah85.
This should be much more prevalent.
https://github.com/llvm/llvm-project/pull/184725
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits