<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I have just now for the second time root-caused yet another "nasty nasty UB bug" from yet another developer who got cut on the very sharp edge of this API:<div class=""><br class=""></div><div class=""> var result = [40,50,60] as [Int8]</div><div class=""> return String(validatingUTF8: result)</div><div class=""><br class=""></div><div class="">This poorly-named String constructor does not take a Swift array of UTF8 bytes, it takes an UnsafePointer to a C string. When that C string is not null-terminated (as shown here), UB ensues.</div><div class=""><br class=""></div><div class="">I believe *<b class="">at least</b>* we need a sane name for this constructor like String(validatingUTF8CString:) that vaguely suggests what the programmer can do to avoid UB.</div><div class=""><br class=""></div><div class="">I further believe that this API is just plain bad, but swift-dev disagrees and so in the interests of doing <i class="">something</i> to stop the bleeding I propose we rename.</div><div class=""><br class=""></div><div class="">Drew</div></body></html>