Add C23's memset_explicit().
https://open-std.org/jtc1/sc22/wg14/www/docs/n2897.htm
Test: treehugger
Change-Id: Ia0cfc72bdf3c22eda6a4fc9adaa4c0ca0ff9a7c8
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index 8d3fb68..30c87dc 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -1673,3 +1673,15 @@
ASSERT_EQ(nullptr, memccpy(dst, "hello world", ' ', 4));
ASSERT_STREQ("hell", dst);
}
+
+TEST(STRING_TEST, memset_explicit_smoke) {
+#if defined(__BIONIC__)
+ // We can't reliably test that the compiler won't optimize out calls to
+ // memset_explicit(), but we can at least check that it behaves like memset.
+ char buf[32];
+ memset_explicit(buf, 'x', sizeof(buf));
+ ASSERT_TRUE(memcmp(buf, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", sizeof(buf)) == 0);
+#else
+ GTEST_SKIP() << "memset_explicit not available";
+#endif
+}