File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3330,6 +3330,11 @@ void CheckClass::checkReturnByReference()
33303330 continue ;
33313331 if (func.isImplicitlyVirtual ())
33323332 continue ;
3333+ if (func.isOperator ())
3334+ continue ;
3335+ if (const Library::Container* container = mSettings ->library .detectContainer (func.retDef ))
3336+ if (container->view )
3337+ continue ;
33333338 if (const Variable* var = getSingleReturnVar (func.functionScope )) {
33343339 if (!var->valueType ())
33353340 continue ;
Original file line number Diff line number Diff line change @@ -8964,6 +8964,19 @@ class TestClass : public TestFixture {
89648964 checkReturnByReference (" struct S { S(); };\n " // #12620
89658965 " S::S() = delete;\n " );
89668966 ASSERT_EQUALS (" " , errout_str ()); // don't crash
8967+
8968+ checkReturnByReference (" struct S {\n " // #12626
8969+ " std::string s;\n "
8970+ " operator std::string_view() const { return s; }\n "
8971+ " std::string_view get() const { return s; }\n "
8972+ " };\n "
8973+ " template<typename T>\n "
8974+ " struct U {\n "
8975+ " T t;\n "
8976+ " operator const T& () const { return t; }\n "
8977+ " };\n "
8978+ " U<std::string> u;\n " );
8979+ ASSERT_EQUALS (" " , errout_str ());
89678980 }
89688981};
89698982
You can’t perform that action at this time.
0 commit comments