On Wed, Jul 1, 2026 at 11:21 PM Jonathan Wakely <[email protected]> wrote:
>
>
>
> On Wed, 1 Jul 2026, 16:10 Jonathan Wakely, <[email protected]> wrote:
>>
>> On Wed, 1 Jul 2026 at 15:47, Tomasz Kaminski <[email protected]> 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.
>
>
> Actually, since we pass __s to the string_view constructor, it cannot ever be 
> null, even if n==0 is true.
>
> If we want to support passing null pointers here, we need to do:
>
> if (n == 0) return
>
> But then we should really have a pedassert that __s != 0 && pos == 0
>
> I think we don't want to support that.
>
> So just remove the checks from these new functions. The preconditions are 
> checked by the string view constructor and substr and the append overload 
> that takes a string view.
>
>

Agreed. Here is the latest patch:
https://gcc.gnu.org/pipermail/gcc-patches/2026-July/722411.html


>>
>>
>>
>> > __glibcxx_requires_string_len(__s, __n);
>> >
>> >
>> >
>> >
>> > On Wed, Jul 1, 2026 at 4:41 PM Yuao Ma <[email protected]> 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
>>

Reply via email to