<div dir="auto"><div><br><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, 1 Jul 2026, 16:19 Nathan Myers, <<a href="mailto:ncm@cantrip.org">ncm@cantrip.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 7/1/26 11:08 AM, Jonathan Wakely wrote:<br>
> On Wed, 1 Jul 2026 at 15:47, Tomasz Kaminski <<a href="mailto:tkaminsk@redhat.com" target="_blank" rel="noreferrer">tkaminsk@redhat.com</a>> wrote:<br>
>><br>
>> Are the following checks correct? I think we need string of at least length __pos + __len.<br>
> <br>
> The macro is defined as:<br>
> #  define __glibcxx_requires_string_len(_String,_Len)    \<br>
>    _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)<br>
> <br>
> So it says we can't have a null pointer unless n==0 is true. I think<br>
> that's the right check here.<br>
> <br>
> <br>
> <br>
>> __glibcxx_requires_string_len(__s, __n);<br>
<br>
<br>
I was a little worried about<br>
<br>
   return assign(__sv_type(__s).substr(__pos, __n));<br>
<br>
It will scan all the way to the end of __s to make the string_view,<br>
and then only use __n of that. Shouldn't it limit the size of the<br>
string_view?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">We find have strnlen in char_traits. This was discussed by lwg and is mentioned in the issue.</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Maybe to __pos + __n; or even to __n and start it at __s + __pos<br>
if predconditions allow.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">They don't. </div><div dir="auto"><br></div><div dir="auto">Consider append("a\0b", 2, 1) which should throw out_of_range.</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
>> On Wed, Jul 1, 2026 at 4:41 PM Yuao Ma <<a href="mailto:addr2line@gmail.com" target="_blank" rel="noreferrer">addr2line@gmail.com</a>> wrote:<br>
>>><br>
>>> Hi!<br>
>>><br>
>>> This patch implements LWG3662 for C++11 ABI and COW ABI of strings.<br>
>>><br>
>>> Tested on x86_64 linux, ok for trunk?<br>
>>><br>
>>> Thanks,<br>
>>> Yuao<br>
> <br>
<br>
</blockquote></div></div></div>