[PATCH] libstdc++: implement LWG3662 basic_string::append/assign(NTBS, pos, n) suboptimal

Jonathan Wakely jwakely@redhat.com
Wed Jul 1 15:08:25 GMT 2026


On Wed, 1 Jul 2026 at 15:47, Tomasz Kaminski <tkaminsk@redhat.com> wrote:
>
> Are the following checks correct? I think we need string of at least length __pos + __len.

The macro is defined as:
#  define __glibcxx_requires_string_len(_String,_Len)    \
  _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)

So it says we can't have a null pointer unless n==0 is true. I think
that's the right check here.



> __glibcxx_requires_string_len(__s, __n);
>
>
>
>
> On Wed, Jul 1, 2026 at 4:41 PM Yuao Ma <addr2line@gmail.com> wrote:
>>
>> Hi!
>>
>> This patch implements LWG3662 for C++11 ABI and COW ABI of strings.
>>
>> Tested on x86_64 linux, ok for trunk?
>>
>> Thanks,
>> Yuao



More information about the Libstdc++ mailing list