[swift-dev] Strange DispatchTime bug
glessard at tffenterprises.com
Sat Aug 26 17:28:03 CDT 2017
> On Aug 26, 2017, at 15:36, David Zarzycki <zarzycki at icloud.com> wrote:
> Without going into details, it looks like the Swift wrappers for dispatch_time_t are very, very broken. In short, dispatch_time_t (in the C world) is intentionally documented as an opaque type, but the Swift wrappers assume otherwise and jump to wrong conclusions about the implementation of the type. What this means in practice is that you should avoid the DispatchTime comparison APIs for now.
They’re not *that* opaque, they’re here:
In any event, the DispatchTime and DispatchWallTime wrappers do not let you initialize them from a raw value and, as such, avoid the duality of dispatch_time_t.
In my example, the runtime is probably not running the comparator it’s supposed to
(the one at https://github.com/apple/swift/blob/92f750aa3c3c4dce47eb55068850f3d1127b16bd/stdlib/public/SDK/Dispatch/Time.swift#L73). We can observe what the values are: some int in the range 1..<(2^63), and 2^64-1. The latter is always greater than the former, yet we’re getting `false` from a less-than operator. Strange.
More information about the swift-dev