Skip to content

Conversation

@ianpartridge
Copy link
Contributor

Warning: Overlapping accesses to 'self', but modification requires exclusive access; consider copying to a local variable

There are more of these in the codebase, but here's a fix for a few.

> Overlapping accesses to 'self', but modification requires exclusive access; consider copying to a local variable

let res: Bool = withUnsafeMutablePointer(to: &at) { t in
let copy = vector
return vector.withUnsafeMutableBufferPointer { (vectorBuffer: inout UnsafeMutableBufferPointer<Int32>) in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would let count = Int32(vector.count) be better to reduce the size of the copy?

XCTAssertEqual(bytes.pointee, 0x67, "First byte should be 0x67")
XCTAssertEqual(mutatingHello[0], 0x67, "First byte accessed via other method should still be 0x67")
XCTAssertEqual(copy[0], 0x67, "First byte accessed via other method should still be 0x67")

Copy link
Contributor

@spevans spevans Nov 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this copy making the test redundant?
Would moving the XCTAssertEqual(mutatingHello[0] ... outside of the closure give the same effect?

@ianpartridge
Copy link
Contributor Author

@swift-ci please test

@spevans
Copy link
Contributor

spevans commented Nov 27, 2017

Those fixes look good.

@ianpartridge
Copy link
Contributor Author

@swift-ci please test and merge

@swift-ci swift-ci merged commit 03e2846 into swiftlang:master Nov 29, 2017
@ianpartridge ianpartridge deleted the exclusive-access branch November 29, 2017 21:15
devincoughlin added a commit to devincoughlin/swift-corelibs-foundation that referenced this pull request Apr 13, 2018
Fix an exclusivity warning in TestNSData by moving assertions outside
outside of a withUnsafeMutableByte() closure. This mirrors the approach
taken by swiftlang#1337
to avoid the analogous warning in a similar test in this file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants