libstdc++: Fix out-of-bound array accesses in testsuite
I fixed some undefined behaviour in string tests in r238609, but I only fixed the narrow char versions. This applies the same fixes to the wchar_t ones. These problems were found when testing a patch to make std::basic_string usable in constexpr. libstdc++-v3/ChangeLog: * testsuite/21_strings/basic_string/modifiers/append/wchar_t/1.cc: Fix reads past the end of strings. * testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/operations/compare/wchar_t/1.cc: Likewise.
This commit is contained in:
parent
9719769471
commit
8d8e8f3ad5
@ -117,7 +117,7 @@ void test01(void)
|
||||
VERIFY( str06 == L"corpus, corpus" );
|
||||
|
||||
str06 = str02;
|
||||
str06.append(L"corpus, ", 12);
|
||||
str06.append(L"corpus, ", 9); // n=9 includes null terminator
|
||||
VERIFY( str06 != L"corpus, corpus, " );
|
||||
|
||||
|
||||
|
@ -81,8 +81,8 @@ test01()
|
||||
test_value(wcsncmp(str_1.data(), str_0.data(), 6), z);
|
||||
test_value(wcsncmp(str_1.data(), str_0.data(), 14), lt);
|
||||
test_value(wmemcmp(str_1.data(), str_0.data(), 6), z);
|
||||
test_value(wmemcmp(str_1.data(), str_0.data(), 14), lt);
|
||||
test_value(wmemcmp(L"costa marbella", L"costa rica", 14), lt);
|
||||
test_value(wmemcmp(str_1.data(), str_0.data(), 10), lt);
|
||||
test_value(wmemcmp(L"costa marbella", L"costa rica", 10), lt);
|
||||
|
||||
// int compare(const basic_string& str) const;
|
||||
test_value(str_0.compare(str_1), gt); //because r>m
|
||||
|
@ -81,8 +81,8 @@ test01()
|
||||
test_value(wcsncmp(str_1.data(), str_0.data(), 6), z);
|
||||
test_value(wcsncmp(str_1.data(), str_0.data(), 14), lt);
|
||||
test_value(wmemcmp(str_1.data(), str_0.data(), 6), z);
|
||||
test_value(wmemcmp(str_1.data(), str_0.data(), 14), lt);
|
||||
test_value(wmemcmp(L"costa marbella", L"costa rica", 14), lt);
|
||||
test_value(wmemcmp(str_1.data(), str_0.data(), 10), lt);
|
||||
test_value(wmemcmp(L"costa marbella", L"costa rica", 10), lt);
|
||||
|
||||
// int compare(const basic_string_view& str) const;
|
||||
test_value(str_0.compare(str_1), gt); //because r>m
|
||||
|
Loading…
Reference in New Issue
Block a user