<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68976>68976</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[runtime] Incorrect output with -ffast-math
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
vfdff
</td>
</tr>
</table>
<pre>
* test: ~/test » cat test.cpp
```
#include <array>
#include <cmath>
#include <limits>
#include <cstdio>
int main()
{
std::array<double, 4> vals;
std::fill(vals.begin(), vals.end(), 0.0f);
vals.back() = std::numeric_limits<double>::infinity();
printf("vals.back(): %f\n", vals.back());
}
```
* output with newest llvm commit **434b8a3080**:
```
~/test » ~/llvm-project-upstream/build/bin/clang test.cpp -O3 -std=c++17 && ./a.out
vals.back(): inf
------------------------------------------------------------
~/test » ~/llvm-project-upstream/build/bin/clang test.cpp -O3 -std=c++17 -ffast-math && ./a.out
vals.back(): 0.000000 --- unexpected result
------------------------------------------------------------
~/test » g++ test.cpp -O3 -std=c++17 -ffast-math && ./a.out
vals.back(): inf
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VM1upDgQfpriYoFMGWg4cOifIO1pH2FlbNPtXWMQtpPNZZ59ZOh0eqLOITOasZBs89V_fWXunD5bpVooD1CeEh78ZVra50EOQ9JP8rUF3BOvnAe2J98Au3gmcEQ4HIjgfsUyMc9AT0D3UNHrt12RaStMkIoAO_Jl4a_Anh5hYuT-8glm9Ki9-0zReamnG0i2TVtPRq4tYA3YXPV2h6sMIcR5CWwPbH8N6iin0BsFeCQFsCfyzI0D9khh0MYA1lEg69X55gOPq1KmrHz_QzM6xOO9pU2Ti_82MQLs9G7dhlEtWvzzlvNbXOxpw7UdtNX-9eri3u68aOuHFcAPPmLzAMsByqMFxFusdxJ3xmB3etzNa_n3ZAp-Dp68aH8hVr1EShjzPBIxjaP2BDBKFazoa85oTbd7TOCR2Y-sivdoLZ2X6V8lfBpm5xfFR8CuD9rIuMeyd8Jwe74xkKR_M5KulTwJwAPgId8RwAqwIiQD7Hg2Bb85fVAgbYcNS39h_YmU0mHgzqdxYsgX8qMZXVfkSpqmJFj1_6yEV5IsygXjf1f25y1y8oW0fqJrN1YlsmWyYQ1PVJtXzS5vqrzE5NLSoh5k3SgqeFkpWqgai1LuhGJ9LvJmSHSLFFlOc5bniCzPGFaiL5pqJ-QgVCGhoGrk2mSxmdm0nBPtXFBtVTe7KjG8V8atTymiVS9kBeO8ladkaVcC9OHsoKBGO-_erXjtzfoGL8F6PSooT-QvK6ZlUcL_MG13RUrCYtqL97OLk4UdYHfW_hL6TEzjlXAfeAfYrTE5wG6N-XsAAAD__8imq0E">