libstdc++: Suppress -Wstringop warnings [PR103332]

libstdc++-v3/ChangeLog:

	PR libstdc++/103332
	PR libstdc++/102958
	* testsuite/21_strings/basic_string/capacity/char/1.cc: Add
	-Wno-stringop-overflow.
	* testsuite/21_strings/basic_string/operators/char/1.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/factory/u8path-char8_t.cc:
	Add -Wno-stringop-overread.
This commit is contained in:
Jonathan Wakely 2021-11-19 18:13:10 +00:00
parent 2d76292bd6
commit b8f2efaed0
3 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-Wno-stringop-overflow" }
// 21.3.3 string capacity
#include <string>
@ -59,6 +61,7 @@ void test01()
std::string str05(30, 'q');
std::string str06 = str05;
// The following triggers -Wstringop-overflow. See PR 103332.
str05 = str06 + str05;
VERIFY( str05.capacity() >= str05.size() );
VERIFY( str06.capacity() >= str06.size() );

View File

@ -17,6 +17,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-Wno-stringop-overflow" }
// 21.3.6 string operations
#include <string>
@ -31,6 +33,7 @@ int test01(void)
// Should get this:
// 1:8-chars_8-chars_
// 2:8-chars_8-chars_
// The following triggers -Wstringop-overread. See PR 103332.
str1 = std::string("8-chars_") + "8-chars_";
str1.c_str();
// printf("1:%s\n", str1.c_str());

View File

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-lstdc++fs -fchar8_t" }
// { dg-options "-lstdc++fs -fchar8_t -Wno-stringop-overread" }
// { dg-do run { target c++11 } }
// { dg-require-filesystem-ts "" }
@ -36,10 +36,12 @@ test01()
p = fs::u8path(u8"\xf0\x9d\x84\x9e");
VERIFY( p.u8string() == u8"\U0001D11E" );
// The following triggers -Wstringop-overread. See PR 103332.
std::u8string s1 = u8"filename2";
p = fs::u8path(s1);
VERIFY( p.u8string() == u8"filename2" );
// The following triggers -Wstringop-overread. See PR 103332.
std::u8string s2 = u8"filename3";
p = fs::u8path(s2.begin(), s2.end());
VERIFY( p.u8string() == u8"filename3" );