diff --git a/cfg/std.cfg b/cfg/std.cfg index 6882548c7..603386f36 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -3884,6 +3884,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun false + diff --git a/test/testother.cpp b/test/testother.cpp index 57ccb4131..594b36f43 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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()); } };