Skip to content
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

[SR-3914] Invalid "Mixed-type subtraction is deprecated." warning Xcode 8.3 beta 2 #46499

keith opened this issue Feb 10, 2017 · 5 comments


Copy link

@keith keith commented Feb 10, 2017

Previous ID SR-3914
Radar rdar://problem/30472072
Original Reporter @keith
Type Bug
Status Resolved
Resolution Won't Do
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, 3.1Regression, TypeChecker
Assignee None
Priority Medium

md5: 8ff5f9ec83e0c164daad3b038df2038b

Issue Description:

This code produces the "Mixed-type subtraction is deprecated." warning even though both `tv_usec` calls return a `_darwin_suseconds_t` aka `_int32_t` aka `Int32`

import Darwin

var bootTime: timeval = timeval()
var now: timeval = timeval()

_ = now.tv_usec - bootTime.tv_usec // Doesn't warn
_ = max(0, now.tv_usec - bootTime.tv_usec) // Doesn't warn
_ = UInt64(max(0, now.tv_usec - bootTime.tv_usec)) // Warns
Copy link

@belkadan belkadan commented Feb 10, 2017

@swift-ci create

Copy link

@belkadan belkadan commented Feb 10, 2017

For some reason it's using the Strideable conformance.

func - <T: Strideable>(lhs: T, rhs: T) -> T.Stride

Copy link

@belkadan belkadan commented Feb 10, 2017

I guess the 0 is providing enough context to suggest an Int return? :-(

Copy link

@belkadan belkadan commented Feb 10, 2017

Keith, you can work around this by using 0 as Int32.

Copy link

@moiseev moiseev mannequin commented Feb 14, 2017

Yeah... Tricky to understand, but correct behavior. Should be worked around for now, until the deprecated overload is not removed in Swift 4.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants