From a9a6e4c086552b08acbb77f599a878f8b60aa4a3 Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Tue, 31 Aug 2021 02:48:50 -0500 Subject: [PATCH] Regression test for 9811: False positive: Reference to temporary returned (#3434) --- test/testautovariables.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 614401126..f4087693a 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -2686,6 +2686,17 @@ private: " return (entry == lookup.end()) ? \"\" : entry->value;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // #9811 + check("struct Base {\n" + " virtual auto get() -> int & = 0;\n" + "};\n" + "struct A : public Base {\n" + " int z = 42;\n" + " auto get() -> int & override { return z; }\n" + " auto getMore() -> int & { return get(); }\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); } void danglingLifetimeFunction() {