[PATCH] Complete __gnu_debug::basic_string Standard conformity

François Dumont frs.dumont@gmail.com
Sun Jul 10 13:56:59 GMT 2022


Here is a first patch to complete __gnu_debug::basic_string Standard 
conformity.

I prefer to submit this before checking for more missing stuff to check 
that my proposal of having a testsuite_string.h header is ok.

I also noticed some problems with _GLIBCXX_DEBUG_PEDANTIC.

     libstdc++: Complete __gnu_debug::string Standard conformity

     Add testsuite/testsuite_string.h header to help testing 
__gnu_debug::basic_string like
     std::basic_string depending on _GLIBCXX_DEBUG.

     Add using of base type methods in __gnu_debug::basic_string to make 
use of the method
     overloads when there is no debug version.

     Fix _GLIBCXX_DEBUG_PEDANTIC assertions in <debug/string>. This 
header has to be used directly
     like __gnu_debug::string, it is not included by _GLIBCXX_DEBUG. It 
means that
     _GLIBCXX_DEBUG_PEDANTIC is not considered to define 
__glibcxx_check_string and
     __glibcxx_check_string_len which are then empty macros. Now those 
macros are defined
     directly in <debug/string> and properly consider 
_GLIBCXX_DEBUG_PEDANTIC.

     libstdc++-v3/ChangeLog:

             * include/debug/debug.h 
[_GLIBCXX_DEBUG](__glibcxx_requires_string): Define
             using _GLIBCXX_DEBUG_PEDASSERT.
             [_GLIBCXX_DEBUG](__glibcxx_requires_string_len): Likewise.
             * include/debug/macros.h
             (__glibcxx_check_string, __glibcxx_check_string_len): Move...
             * include/debug/string
             (__glibcxx_check_string, __glibcxx_check_string_len): 
...here. And define depending
             on _GLIBCXX_DEBUG_PEDANTIC no matter if _GLIBCXX_DEBUG is 
defined.
             Add using of std::string find, rfind, find_first_of, 
find_last_of, find_first_not_of
             and find_last_not_of. Remove debug implementations having 
no debug assertion.
             * testsuite/util/testsuite_string.h: New file. Provides 
__gnu_test::string and
             __gnu_test::wtring which definition depends on _GLIBCXX_DEBUG.
             * testsuite/21_strings/basic_string/debug/find1_neg.cc: New 
test case.
             * testsuite/21_strings/basic_string/debug/find2_neg.cc: New 
test case.
             * 
testsuite/21_strings/basic_string/operations/find/char/1.cc: Include 
<testsuite_string.h>
             and use __gnu_test::string.
             * 
testsuite/21_strings/basic_string/operations/find/char/2.cc: Likewise.
             * 
testsuite/21_strings/basic_string/operations/find/char/3.cc: Likewise.
             * 
testsuite/21_strings/basic_string/operations/find/char/4.cc: Likewise.
             * 
testsuite/21_strings/basic_string/operations/find/char/5.cc: Likewise.
             * 
testsuite/21_strings/basic_string/operations/find/char/6.cc: Likewise.
             * 
testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc: Include 
<testsuite_string.h>
             and use __gnu_test::wstring.
             * 
testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc: Likewise.
             * 
testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc: Likewise.
             * 
testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc: Likewise.
             * 
testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc: Likewise.
             * 
testsuite/21_strings/basic_string/operations/find/wchar_t/6.cc: Likewise.

Tested under Linux x86_64.

Ok to commit ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug_string.patch
Type: text/x-patch
Size: 23428 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20220710/67d1cd3c/attachment-0001.bin>


More information about the Libstdc++ mailing list