[swift-dev] quick, spot the UB in this code:

Daniel Dunbar daniel_dunbar at apple.com
Wed Apr 6 23:54:03 CDT 2016


Could we get a method that takes a [UInt8] directly and performs the same basic function? In my experience I have frequently wanted such a thing (primarily when debugging things) when working with binary protocols that have embedded ASCII data.

 - Daniel

> On Apr 6, 2016, at 9:51 PM, Dmitri Gribenko via swift-dev <swift-dev at swift.org> wrote:
> 
> On Wed, Apr 6, 2016 at 9:16 PM, Drew Crawford via swift-dev
> <swift-dev at swift.org> wrote:
>> and it should crash
>> deterministically if it gets non-terminated bytes, or
> 
> It can't, how would you check for this, only given a pointer?
> 
>> 2.  It should not require null-terminated bytes
> 
> This operation converts a C string to a Swift string, so (2) is a non-starter.
> 
> Dmitri
> 
> -- 
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
> _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev



More information about the swift-dev mailing list