[PATCH] Complete __gnu_debug::basic_string Standard conformity
Jonathan Wakely
jwakely@redhat.com
Tue Jul 19 10:42:44 GMT 2022
On Sun, 10 Jul 2022 at 14:57, François Dumont via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> 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 think this change means some testcases will never test std::string
with _GLIBCXX_DEBUG defined, because if that is defined they test
__gnu_debug::string instead. That means assertions in
std::basic_string like this one will not get tested:
template<typename _CharT, typename _Traits, typename _Alloc>
_GLIBCXX_STRING_CONSTEXPR
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
find(const _CharT* __s, size_type __pos, size_type __n) const
_GLIBCXX_NOEXCEPT
{
__glibcxx_requires_string_len(__s, __n);
Are we OK with never testing those assertions?
Currently they don't get tested by default because of the extern
template declarations for std::string, so they would only be tested
with -std=c++20 -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC, which I
don't test routinely. So I suppose this change doesn't make things any
worse in practice.
> 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.
Nice catch.
OK for trunk, thanks.
More information about the Libstdc++
mailing list