<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60080>60080</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Miscompilation of code involving static floating point arrays
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Omnifarious
</td>
</tr>
</table>
<pre>
When compiled by clang 15.0.0 with `-std=c++20 -O3 -march=znver2`, this smallcode snippet compiles to assembly that appears to bear little or no resemblance to the code:
```lang-cpp
static float ary[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
static float ary2[] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
float test()
{
ary2[10] = 21;
return ary2[10];
}
float touch_arrays(float x)
{
float result;
for (auto &i: ary) {
i = x++;
result += i;
}
for (auto &i: ary2) {
i = x++;
result += i;
}
return result;
}
```
https://compiler-explorer.com/z/s9K7Tj15d
In particular this results in the compiler emitting two functions that simply return a float NaN.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslE-P8yYQxj8NvowSwRD_O_jQ1IpUVX3fS6UeK2yTmBUGC3B2s5--Aju762rVU6PoiWLw85sZZhDeq5uRsiH5meRtJpYwWtf8nIy6Cqfs4rPODo_mr1Ea6O00Ky0H6B7Qa2FuwPIjPVJ4VWEEUtCDDwPhbU_wTPCMFA4_ORwm4fqR8Pbd3KVDUlCCv0IYlQc_Ca17O0jwRs2zDE-Eh2BBeC-nTj8gjCKAmGcpXFropHCgVQhagnVgLDiZtgrTy7ghjBKiLeG_ENoS-tSCrt8Y-6Gf5_WxDyKoHq7aRox7rKUAwlsg5TlFy6JgFB7lFCWPUkQpo1RR6rSZkrIl_Py9O-7tWbJmyZslc5bcWbJnyZ8lAEsElhC4Q6y6EoL0gWBFsN7Wym3Tk83ok47swwEAwMmwOLPb9kko229QdunHv4Vz4uEJVuvDt2_IAFv6TvpFhx31ah0QrMQSLBAsFOEpUoI17AziR6Ww39bu2rms8UdzSEstqN36R_z_gcQ983-CbVX9V-af9Xy25NfyjiHMPvYuXghetpFwB_k2a-ukO_Z2Inh5J3jx9e_lny8sH76-_puBWbig-kULtw7aivegzDYbqyXISYWgzA3Cq4XrYvqgrPHrwHk1zfrx0RbbEf4QP47Z0PCh5rXIZMOKklc1xZJlY9N1FcN-qHlV1CdeCZQlrfKhKE4V431-zVSDFDllrGAlZ4wdCzGwCutKDHkur6cTOVE5CaWPWt-no3W3THm_yKagtKKZFp3UPt1ViEa-QlokiPHqck1859AtN09OVCsf_KdLUEHL5g_l19RFzBPsNd0SoMzd6nssw9dhjf9nq0yc2tji2eJ0sz-amwrj0m3nEVnbz2F29kX2geAlRegJXlIG_wQAAP__uo-Pgw">