Re: [swift-corelibs-dev] [swift-dev] Foundation Data Behavior Different (read: crashes) in Swift 3.1 and Swift 3.2

2017-08-24 Thread Philippe Hausler via swift-corelibs-dev
This is expected behaviors of collections and their slices. The previous result was a bug. I agree that collections in general and their slices need more documentation. Sent from my iPhone > On Aug 24, 2017, at 11:28 AM, Ryan Lovelett > wrote: > > I think your onto it Philippe but then why i

Re: [swift-corelibs-dev] [swift-dev] Foundation Data Behavior Different (read: crashes) in Swift 3.1 and Swift 3.2

2017-08-24 Thread Ryan Lovelett via swift-corelibs-dev
I think your onto it Philippe but then why is it behaving that way? I updated my earlier script (attached) and added 2 things. 1. print("Start: \(data.startIndex), End: \(data.endIndex), Count: \(data.count)") after the data.removeFirst(4). 2. The startIndex offset you suggested. It no

Re: [swift-corelibs-dev] [swift-dev] Foundation Data Behavior Different (read: crashes) in Swift 3.1 and Swift 3.2

2017-08-24 Thread Philippe Hausler via swift-corelibs-dev
I see the issue.. the latest version traps (appropriately so). let str = String(bytes: data[0..<2], encoding: .utf8)! The sub-range of the slice you have is incorrectly indexed. Try this out (I am presuming this is what you mean): let str = String(bytes: data[data.startIndex..<(data.startIndex

Re: [swift-corelibs-dev] [swift-dev] Foundation Data Behavior Different (read: crashes) in Swift 3.1 and Swift 3.2

2017-08-24 Thread Philippe Hausler via swift-corelibs-dev
Is there a radar or bugs.swift.org ticket filed on this? I presume because of the import this is a Darwin thing and not a linux thing. > On Aug 24, 2017, at 11:05 AM, Michael Gottesman via swift-dev > wrote: > > >> On Aug 24, 2017, at 10:47 AM, Ryan Lovelett via swift-dev >> wrote: >> >> I

Re: [swift-corelibs-dev] [swift-dev] Foundation Data Behavior Different (read: crashes) in Swift 3.1 and Swift 3.2

2017-08-24 Thread Michael Gottesman via swift-corelibs-dev
> On Aug 24, 2017, at 10:47 AM, Ryan Lovelett via swift-dev > wrote: > > I've found what I believe is a bug. Though I'm unclear if the bug is in > Swift 3.1 or Swift 3.2/4.0. All I can say for sure is the behavior is > quite drastically different between the two. > > For the code below (and at

[swift-corelibs-dev] Foundation Data Behavior Different (read: crashes) in Swift 3.1 and Swift 3.2

2017-08-24 Thread Ryan Lovelett via swift-corelibs-dev
I've found what I believe is a bug. Though I'm unclear if the bug is in Swift 3.1 or Swift 3.2/4.0. All I can say for sure is the behavior is quite drastically different between the two. For the code below (and attached): import Cocoa var data = Data(bytes: [0x50, 0x4B, 0x01, 0x02, 0x41,