Merge pull request #2731 from pfultz2/dangling-container-value-type
Fix issue 9770: FP returnDanglingLifetime for class method taking const char* and returning std::string
This commit is contained in:
commit
4fabd1e059
|
@ -3068,7 +3068,7 @@ static bool isLifetimeBorrowed(const ValueType *vt, const ValueType *vtParent)
|
|||
return false;
|
||||
if (!vt)
|
||||
return false;
|
||||
if (vt->type != ValueType::UNKNOWN_TYPE && vtParent->type != ValueType::UNKNOWN_TYPE) {
|
||||
if (vt->type != ValueType::UNKNOWN_TYPE && vtParent->type != ValueType::UNKNOWN_TYPE && vtParent->container == vt->container) {
|
||||
if (vtParent->pointer > vt->pointer)
|
||||
return true;
|
||||
if (vtParent->pointer < vt->pointer && vtParent->isIntegral())
|
||||
|
|
|
@ -2328,6 +2328,16 @@ private:
|
|||
" return value;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #9770
|
||||
check("class C {\n"
|
||||
" std::string f(const char*);\n"
|
||||
"};\n"
|
||||
"std::string C::f(const char*) {\n"
|
||||
" const char data[] = \"x\";\n"
|
||||
" return data;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void danglingLifetimeFunction() {
|
||||
|
|
Loading…
Reference in New Issue