1 Reply
      Latest reply on May 14, 2019 5:27 AM by john daniel
      LarryM Level 1 Level 1 (0 points)

        I am in the process of moving an existing project to XCode 10.2 on Mojave, and I discovered a very disturbing behavior when converting a float to an int with the "-Ofast" compiler optimization option.  In one of my C++ modules, I have the following statement:

         

        int nVal1 = (int)sqrt((float)nNumImgsOnPage);

         

        where nNumImgsOnPage is also declared as int.

         

        When nNumImgsOnPage == 1, this operation incorrectly returns 0 when the project is compiled with -Ofast and 1 when compiled with other optimzation levels.

         

        Is this a known bug in the Apple Clang compiler?  Are there other such bugs?

         

        Thank You

         

         

        Larry