<p dir="ltr">Hi all,</p>
<p dir="ltr">We can't assume StringRef is null terminated, ever.</p>
<p dir="ltr">Vince<br>
</p>
<div class="gmail_quote">On Feb 23, 2015 4:48 PM, "Joerg Sonnenberger" <<a href="mailto:joerg@britannica.bec.de">joerg@britannica.bec.de</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Feb 23, 2015 at 05:31:50PM +0000, Zachary Turner wrote:<br>
> How so? Suppose you've got a function which takes a const char*. Obviously<br>
> it's null terminated or your function wouldn't be able to work. If you<br>
> replace that with a StringRef it's still null terminated because the call<br>
> site hasn't changed. Either way, its up to the caller to pass something<br>
> null terminated.<br>
><br>
> Any time you construct a StringRef from a std::string or ConstString, which<br>
> is very close to 100% of what we do, the StringRef is guaranteed to be null<br>
> terminated.<br>
<br>
But StringRef is normally a part of either a std::string or const char *.<br>
While there might be a null byte somewhere, it has no relation to the<br>
size of the string referenced by StringRef. The point is that accessing<br>
the data of a StringRef doesn't give a null terminated string of the<br>
same size as the StringRef, if at all.<br>
<br>
Joerg<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>