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

Joe Groff jgroff at apple.com
Wed Sep 7 12:01:46 CDT 2016


> On Sep 7, 2016, at 6:47 AM, louislepegue via swift-dev <swift-dev at swift.org> wrote:
> 
> Hi
> 
> This simple instruction can take more than 20 seconds to execute  and near 100% CPU on different Linux Swift version I tested.
> Also tested in compiled mode with the same result.
> 
> let simpleTest = Float(abs(11 - -3) + abs(4.5 - -4))  //!
> print ("simpleTest:  \(Simpletest)")
> 
> I know that a many variations can cause more or less results I can't determine if Float or abs is the culprit.
> 
> Do someone have an idea on this ?

We'd appreciate some more information on how exactly you're compiling the above code. Are you running it as a script with `swift`, or compiling it then executing it? Are you optimizing? Running a script with `swift` will include type checking and code generation time, and we have some known compiler performance issues with heavily-overloaded operators such as the numeric operators.

-Joe


More information about the swift-dev mailing list