]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix sizeof(wide-string)-1 bug in std::regex test
authorJonathan Wakely <jwakely@redhat.com>
Wed, 1 Oct 2025 12:11:38 +0000 (13:11 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 1 Oct 2025 14:31:08 +0000 (15:31 +0100)
This uses sizeof on a wide string to get the length, which is wrong
because each wchar_t is more than one byte. This was presumably copied
from a narrow char test.

libstdc++-v3/ChangeLog:

* testsuite/28_regex/basic_regex/assign/wchar_t/pstring.cc: Use
wcslen(cs) instead of sizeof(cs)-1.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
libstdc++-v3/testsuite/28_regex/basic_regex/assign/wchar_t/pstring.cc

index 2e9dea13a7744e73c75a2eded52a2a377dc515b4..91e55129908c655f619400b3964a8d0f1d573160 100644 (file)
@@ -23,6 +23,7 @@
 // [28.8.3] class template basic_regex assign()
 
 #include <regex>
+#include <cwchar>
 
 // Tests assign operation from a Pascal-style counted-string.  
 void test01()
@@ -31,7 +32,7 @@ void test01()
 
   const wchar_t cs[] = L"aab";
   test_type re;
-  re.assign(cs, sizeof(cs)-1, std::regex_constants::basic);
+  re.assign(cs, std::wcslen(cs), std::regex_constants::basic);
 }
 
 int