Improve librarys config of substr to improve checking cases in issue 8021 (#2338)
This commit is contained in:
parent
c358688c68
commit
650408a210
27
cfg/std.cfg
27
cfg/std.cfg
|
@ -6655,8 +6655,33 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
|||
<returnValue type="std::size_t"/>
|
||||
<noreturn>false</noreturn>
|
||||
</function>
|
||||
<function name="std::string::substr,std::wstring::substr,std::basic_string::substr">
|
||||
<function name="std::string::substr">
|
||||
<use-retval/>
|
||||
<returnValue type="std::string"/>
|
||||
<noreturn>false</noreturn>
|
||||
<arg nr="1" default="0" direction="in">
|
||||
<not-uninit/>
|
||||
<valid>0:</valid>
|
||||
</arg>
|
||||
<arg nr="2" default="0" direction="in">
|
||||
<not-uninit/>
|
||||
</arg>
|
||||
</function>
|
||||
<function name="std::wstring::substr">
|
||||
<use-retval/>
|
||||
<returnValue type="std::wstring"/>
|
||||
<noreturn>false</noreturn>
|
||||
<arg nr="1" default="0" direction="in">
|
||||
<not-uninit/>
|
||||
<valid>0:</valid>
|
||||
</arg>
|
||||
<arg nr="2" default="0" direction="in">
|
||||
<not-uninit/>
|
||||
</arg>
|
||||
</function>
|
||||
<function name="std::basic_string::substr">
|
||||
<use-retval/>
|
||||
<returnValue type="std::basic_string"/>
|
||||
<noreturn>false</noreturn>
|
||||
<arg nr="1" default="0" direction="in">
|
||||
<not-uninit/>
|
||||
|
|
|
@ -2452,6 +2452,15 @@ private:
|
|||
ASSERT_EQUALS(
|
||||
"[test.cpp:3] -> [test.cpp:4]: (error) Using pointer to temporary.\n",
|
||||
errout.str());
|
||||
|
||||
check("auto f(std::string s) {\n"
|
||||
" const char *x = s.substr(1,2).c_str();\n"
|
||||
" auto i = s.substr(4,5).begin();\n"
|
||||
" return *i;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(
|
||||
"[test.cpp:3] -> [test.cpp:4]: (error) Using iterator to temporary.\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void invalidLifetime() {
|
||||
|
|
Loading…
Reference in New Issue