[swift-users] Linux Swift: Strange bug found in a simple arithmetic

Alex Blewitt alblue at apple.com
Wed Sep 7 09:33:31 CDT 2016


On 7 Sep 2016, at 15:11, louislepegue via swift-users <swift-users at swift.org> wrote:
> 
> let simpleTest = Float(abs(11 - -3) + abs(4.5 - -4))  //!
> print ("simpleTest:  \(Simpletest)")
> 

Aside from the fact that the case-sensitivity of simpleTest is important, the delay is in the compilation of this script rather than the runtime performance of the script. You can compile it with swiftc (which takes around 20s) but then when running it the performance is fine.

It's certainly an interesting compiler issue, probably to do with the type analysis rather than the complexity of the abs function or the Float cast directly. It's still worth raising a bug at https://bugs.swift.org <https://bugs.swift.org/> with the snippet though.

Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160907/051e7836/attachment.html>


More information about the swift-users mailing list