title: VC++ using fp:fast causes wrong (not just inaccurate) results - is this a compiler bug?
body: <p>I've installed the latest VS2017 update (15.4.4), and when compiling our projects the unit tests started failing.
  It seems that the problem happens in some scenarios when using optimizations (/O2) and fast model for floating point (/fp:fast).
  This problem did not happen with a previous compiler (VS2017 update 15.2).</p>
  
  <p>Here's a sample program:    </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  const float FACTOR = 0.01745329251994329576923690768489f;
  
  unsigned long long hoursToMicrosecs(int hours)
  {
      return hours * 3600 * 1000000LL;
  }
  
  float degToRad(float deg)
  {
      return deg * FACTOR;
  }
  
  float f(int u1, int u2)
  {
      float percent = ((u1 - u2) / 1000.0f) / (hoursToMicrosecs(24) / 1000000.0f);
      return degToRad(percent * 360);
  }
  
  int main()
  {   
      auto result = f(3600000, 35063681);
      std::cout &lt;&lt; result &lt;&lt; '\n';
      return (result &gt; -3.0f) ? 0 : -1;
  }
  </code></pre>
  
  <p><code>result</code> should be -2.2881, but the output is actually -394.868, which is not just inaccurate. </p>
  
  <p>It works if I do any of the following:</p>
  
  <ul>
  <li>Remove optimizations </li>
  <li>Change to fp:precise</li>
  <li>Return to the previous compiler (15.2)</li>
  </ul>
  
  <p>Looking at the disassembly shows us that the compiler tried doing something nice for us - it just calculated the whole thing at compile time and replaced with a single number.</p>
  
  <p>The optimized code is just a one-liner:</p>
  
  <pre><code>011F1000  vmovss      xmm0,dword ptr [__real@c3c56f11 (011F2118h)]  
  </code></pre>
  
  <p>My question is: Is this a compiler bug (which I should report) or is it wrong usage of fp:fast?</p>