public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][_GLIBCXX_DEBUG] Add basic_string::starts_with/ends_with checks
@ 2022-08-14 15:32 François Dumont
  2022-08-15 20:26 ` François Dumont
  2022-08-26  9:31 ` Jonathan Wakely
  0 siblings, 2 replies; 7+ messages in thread
From: François Dumont @ 2022-08-14 15:32 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc-patches

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-08-31  9:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-14 15:32 [PATCH][_GLIBCXX_DEBUG] Add basic_string::starts_with/ends_with checks François Dumont
2022-08-15 20:26 ` François Dumont
2022-08-25 16:11   ` François Dumont
2022-08-26  9:33     ` Jonathan Wakely
2022-08-26  9:31 ` Jonathan Wakely
2022-08-31  4:38   ` [PATCH][_GLIBCXX_DEBUG] Review null string assertions (was: Add basic_string::starts_with/ends_with checks) François Dumont
2022-08-31  9:25     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).