std.cfg: Added not-overlapping-data configuration to wmemcpy()

This commit is contained in:
orbitcowboy 2021-07-08 17:12:53 +02:00
parent 140aa6afb4
commit 3e7b6f262d
2 changed files with 20 additions and 0 deletions

View File

@ -3884,6 +3884,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<returnValue type="wchar_t *"/>
<noreturn>false</noreturn>
<leak-ignore/>
<not-overlapping-data ptr1-arg="1" ptr2-arg="2" size-arg="3"/>
<arg nr="1" direction="out">
<not-null/>
<minsize type="argvalue" arg="3"/>

View File

@ -9342,6 +9342,25 @@ private:
" memcpy(a, a+1, 2u);\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Overlapping read/write in memcpy() is undefined behavior\n", errout.str());
// wmemcpy
check("void foo() {\n"
" wchar_t a[10];\n"
" wmemcpy(&a[5], &a[4], 2u);\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Overlapping read/write in wmemcpy() is undefined behavior\n", errout.str());
check("void foo() {\n"
" wchar_t a[10];\n"
" wmemcpy(a+5, a+4, 2u);\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Overlapping read/write in wmemcpy() is undefined behavior\n", errout.str());
check("void foo() {\n"
" wchar_t a[10];\n"
" wmemcpy(a, a+1, 2u);\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Overlapping read/write in wmemcpy() is undefined behavior\n", errout.str());
}
};