Skip to content

Commit

Permalink
std.cfg: Added not-overlapping-data configuration to wmemcpy()
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitcowboy committed Jul 8, 2021
1 parent 140aa6a commit 3e7b6f2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
19 changes: 19 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9342,6 +9342,25 @@ class TestOther : public TestFixture {
" 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());
}
};

Expand Down

0 comments on commit 3e7b6f2

Please sign in to comment.