[PATCH][_GLIBCXX_DEBUG] Add basic_string::starts_with/ends_with checks
François Dumont
frs.dumont@gmail.com
Thu Aug 25 16:11:26 GMT 2022
I spent more time on this.
Is there some discussion in the C++ Standard Committee to do something
like what I've done ? I guess adding nullptr_t overloads for all the
methods taking pointer is not an option, is it ?
Note that compilation fails but despite the dg-do xfail the test ends up
FAIL and not XFAIL. Is this the correct syntax:
// { dg-do compile { target c++2a xfail *-*-* } }
?
Thanks,
François
On 15/08/22 22:26, François Dumont wrote:
> With the patch !
>
> On 14/08/22 17:32, François Dumont wrote:
>> I think we can add those checks.
>>
>> Note that I wonder if it was needed as in basic_string_view I see
>> usages of __attribute__((__nonnull__)). But running the test I saw no
>> impact even after I try to apply this attribute to the
>> starts_with/ends_with methods themselves.
>>
>> Also note that several checks like the ones I am adding here are
>> XFAILS when using 'make check' because of the segfault rather than on
>> a proper debug checks. Would you prefer to add dg-require-debug-mode
>> to those ?
>>
>> libstdc++: [_GLIBCXX_DEBUG] Add
>> basic_string::starts_with/ends_with checks
>>
>> Add simple checks on C string parameters which should not be null.
>>
>> Review null string checks to show:
>> _String != nullptr
>>
>> rather than:
>> _String != 0
>>
>> libstdc++-v3/ChangeLog:
>>
>> * include/bits/basic_string.h (starts_with, ends_with):
>> Add __glibcxx_check_string.
>> * include/bits/cow_string.h (starts_with, ends_with):
>> Likewise.
>> * include/debug/debug.h: Use nullptr rather than '0' in
>> checks in C++11.
>> * include/debug/string: Likewise.
>> *
>> testsuite/21_strings/basic_string/operations/ends_with/char.cc: Use
>> __gnu_test::string.
>> *
>> testsuite/21_strings/basic_string/operations/ends_with/wchar_t.cc:
>> Use __gnu_test::wstring.
>> *
>> testsuite/21_strings/basic_string/operations/starts_with/wchar_t.cc:
>> Use __gnu_test::wstring.
>> *
>> testsuite/21_strings/basic_string/operations/starts_with/char.cc: Use
>> __gnu_test::string.
>> *
>> testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc:
>> New test.
>> *
>> testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc:
>> New test.
>> *
>> testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc:
>> New test.
>> *
>> testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc:
>> New test.
>>
>> Tested under linux normal and debug modes.
>>
>> François
>>
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nullptr_t.patch
Type: text/x-patch
Size: 4724 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20220825/a0015b87/attachment.bin>
More information about the Libstdc++
mailing list