<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57869>57869</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang-cl 14 /fp:strict not behaving the same as clang -ffp-model=strict (or MSVC?)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          barrettcolin
      </td>
    </tr>
</table>

<pre>
    Given this test code

        #include <cstdio>

        namespace
        {
                static const float SANDBOX_EXTENTS = 25.f;
        }

        int main()
        {
                float vals1[2];
                float vals2[2];
                for(int i = 0; i < 2; ++i)
                {
                        vals1[i] = -SANDBOX_EXTENTS * 0.6f + float(i) * SANDBOX_EXTENTS * 1.2f;
                        vals2[i] = SANDBOX_EXTENTS * (float(i) * 1.2f - 0.6f);
                }

                for(int i = 0; i < 2; ++i)
                {
                        std::printf("old calc result: %f, new calc result: %f (should be same!)\n", vals1[i], vals2[i]);
                }
        }

clang 13.0.1 (I used godbolt) produces this output with "-O2"

        old calc result: -15.000001, new calc result: -15.000001 (should be same!)
        old calc result: 15.000001, new calc result: 15.000001 (should be same!)

clang 14.0.0 (godbolt again) produces this output with "-O2" (note that the calculated results are not the same now, see second line)

        old calc result: -15.000001, new calc result: -15.000001 (should be same!)
        old calc result: 15.000000, new calc result: 15.000001 (should be same!)

clang 14.0.0 produces this output with "-O2 -ffp-model=strict" (consistent output with clang 13 again)

        old calc result: -15.000001, new calc result: -15.000001 (should be same!)
        old calc result: 15.000001, new calc result: 15.000001 (should be same!)

Using clang-cl (LLVM 14.0.6 downloaded from github), passing "/O2" produces this output (note again, difference in calculated results):

        old calc result: -15.000001, new calc result: -15.000001 (should be same!)
        old calc result: 15.000000, new calc result: 15.000001 (should be same!)

Passing "/O2 /fp:strict" produces the same output (still with a difference in calculated results)

        old calc result: -15.000001, new calc result: -15.000001 (should be same!)
        old calc result: 15.000000, new calc result: 15.000001 (should be same!)

I'd expect the program compiled with clang 14 using "-ffp-model=strict" to behave the same as the program compiled with clang-cl 14 using "/fp:strict"?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdVk1vozAQ_TVwsYLAhCQcOKRJs6rUj5XarXpbGTwkXjkYYdPu_vsdm6QhX20PlbbaCCU4nnlv5nlmIFf8T_ZNPENFzEpoYkAbUigOXjj3wun2O_VoLKpCthyIF88KbbhQXnx5YFWxNeiaFbDzG1_s7sNUG2ZEgQQV0pRSMUPup7fzi7unn5dPD5e3D_cIPyc0CUov7nmO5wdMojJkzUTl0YlH03N0HcMzkzrykgvqJfM91L4BPWOgGqSwbMJFFuK-u50Ram89eoGX2IvhKAy8tjEIpHBAg6O86ZSEwai0kJ00lhiB3c4p6yig5UG4GybaZzrlitBHFBaODFwMNp0D4KMT-ERxsJq8eIpX3SBY6c6UKslJwWRBGtCtNLiLeAluzkgFL6e2bFZ6pVp0zIForEWPRpY8mWGdUOvZP4btmr6u30j6UIBCsmpJojgIg8jyXpFWAydLxXOFEaGkdaN4W4Du-kq1pm4NeRFmheZ0cEdtRPuKnsh4ECVBaD_Rmbx3BmezfwP-PfQPg_ckGaIkobXfaEHY0vXphxSxfpUygCbYl2YFLqJWMoPidnFpwhogaOS2bSi4eLEJaMA14GzhRIoKDsL7pwKHny7we2KSQVnWgzVOcomtqU0jCrMR2E5foQ1g3_b9tiX9emBfRr1PKc8fWmB6LslBIa3H9fXjTSfniHD1UuFA5FhmZaPWZImKtLmFQOqaaefshsiiK9ST-m-rd6PgjHBRltBAVQAR1YladjNn-mWE_pQy_X6gFt4syhphdkXYE2_TwjsBtRFSdhXJPqTffyXelUfHnMDvGopuwKFUy4at8ZVpXQuJmfd7dYhPnY3UZ9rdKORasWfYSc30e8C2P_rYRwfoxQsfsmg0isfJOB2nPs9insYp840wErI-yr6zG9wuIovdj6lL6UQaVjbVkJv7xxnyol5-28hsZUytbe9Q_GvRtWuAueBCyuftzwCz_AU25oXQugUsmEUynoxSf5WxYZnmE5pPEhqyIuScsqSMR3E-TPIkTqkvWQ5SZ_h6gCnbg3UQNv1k7ouMhpSGKY2iMMHUg7zIQ8ryCCbjSU6HpTcMAd9QZWDjCFSz9JvMhZS3S42bEkew3m3apllWAI4O8VlrVqrJctY0YEyh8InmO_7Mxf8X98Bizg">