From 3e7b6f262d71233161c0e7511bf1a63faffc11fa Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Thu, 8 Jul 2021 17:12:53 +0200 Subject: [PATCH] std.cfg: Added not-overlapping-data configuration to wmemcpy() --- cfg/std.cfg | 1 + test/testother.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) 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()); } };