Skip to content

Several compilation warnings resolved #1106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Foundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,6 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
@inline(__always)
public func subdata(in range: Range<Index>) -> Data {
_validateRange(range)
let length = count
if count == 0 {
return Data()
}
Expand Down
2 changes: 1 addition & 1 deletion TestFoundation/HTTPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class _TCPSocket {
}

func writeRawData(_ data: Data) throws {
let x = try data.withUnsafeBytes { ptr in
_ = try data.withUnsafeBytes { ptr in
try attempt("write", valid: isNotNegative, CInt(write(connectionSocket, ptr, data.count)))
}
}
Expand Down
6 changes: 4 additions & 2 deletions TestFoundation/TestNSIndexPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ class TestNSIndexPath: XCTestCase {
let ip2: IndexPath = [1, 1, 1]

XCTAssertNotEqual(ip1.hashValue, ip2.hashValue)

IndexPath(indexes: [Int.max >> 8, 2, Int.max >> 36]).hashValue // this should not cause an overflow crash

// this should not cause an overflow crash
let hash: Int? = IndexPath(indexes: [Int.max >> 8, 2, Int.max >> 36]).hashValue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this reasonable? Or is guaranteed that compiler will not optimize out the below to a no-op?

_ = IndexPath(indexes: [Int.max >> 8, 2, Int.max >> 36]).hashValue

Copy link
Contributor

Choose a reason for hiding this comment

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

eh the assert below validates the non-crash case; and it is a test of an overflow so I think it should be fine as you have it

XCTAssertNotNil(hash)
}

func testEquality() {
Expand Down