Re: [swift-users] Swift 4.0 bug in concurrent array access

2018-01-08 Thread C. Keith Ray via swift-users
It's up to the programmer-user to impose thread-safety around an array or other data structure. The compiler doesn't know if you want to allow multiple threads to write and read multiple array members, or prevent all but one thread to read and write multiple array members, or allow multiple rea

Re: [swift-users] Swift 4.0 bug in concurrent array access

2018-01-08 Thread ‫Fadi Botros‬ ‫ via swift-users
What about double checking? Something like that if counter != 0 { throw exc } counter += 1if counter != 1 { throw exc }counter += 1 I think the performance penalty is just a check and an increment It could be disabled after optimization or in release version to increase performance من: G

Re: [swift-users] Swift 4.0 bug in concurrent array access

2018-01-08 Thread Jordan Rose via swift-users
That sounds expected to me. While Array values are thread-safe, writing to the global variable 'array' from two different threads would be a race. You can see this properly diagnosed if you enable Thread Sanitizer. Jordan P.S. bugs.swift.org should be back up now, if you find any other issues.