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

2016-04-06 Thread Dmitri Gribenko via swift-dev
On Wed, Apr 6, 2016 at 10:03 PM, Drew Crawford wrote: > > On Apr 6, 2016, at 11:51 PM, Dmitri Gribenko wrote: > > This operation converts a C string to a Swift string, so (2) is a > non-starter. > > > Then it is inappropriately named. The name of the constructor is > `validatingUTF8`, not `cStri

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

2016-04-06 Thread Drew Crawford via swift-dev
> On Apr 6, 2016, at 11:51 PM, Dmitri Gribenko wrote: > > This operation converts a C string to a Swift string, so (2) is a non-starter. Then it is inappropriately named. The name of the constructor is `validatingUTF8`, not `cString`.___ swift-dev

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

2016-04-06 Thread Daniel Dunbar via swift-dev
> On Apr 6, 2016, at 9:58 PM, Dmitri Gribenko wrote: > > On Wed, Apr 6, 2016 at 9:54 PM, Daniel Dunbar wrote: >> Could we get a method that takes a [UInt8] directly and performs the same >> basic function? > > I think the root of the surprise here is that the compiler converts > [UInt8] into

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

2016-04-06 Thread Dmitri Gribenko via swift-dev
On Wed, Apr 6, 2016 at 9:54 PM, Daniel Dunbar wrote: > Could we get a method that takes a [UInt8] directly and performs the same > basic function? I think the root of the surprise here is that the compiler converts [UInt8] into an unsafe pointer. This is appropriate when the callee is a C API,

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

2016-04-06 Thread Daniel Dunbar via swift-dev
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 Gr

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

2016-04-06 Thread Dmitri Gribenko via swift-dev
On Wed, Apr 6, 2016 at 9:16 PM, Drew Crawford via swift-dev 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