https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95174
Bug ID: 95174 Summary: [D] Incorrect compiled functions involving const fixed size arrays Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: d Assignee: ibuclaw at gdcproject dot org Reporter: witold.baryluk+gcc at gmail dot com Target Milestone: --- https://explore.dgnu.org/z/LppySp ``` void f(immutable(float[64]) x, float[64] o) { o[] = x[] * 2.0f; } ``` and ``` void f(immutable(float[64]) x, float[64] o) { foreach (i; 0 .. 64) { o[i] = x[i] * 2.0f; } } ``` and ``` void f(immutable(float[64]) x, float[64] o) { o[1] = x[5] + x[7]; } ``` Is incorrectly compiled to 'nop; ret' It appears DMD (v2.092) also essentially do the same, and do not perform any computations in the function. LDC2 (1.20.1, based on DMD v2.090.1) does generate correct code in some cases (fully unrolled and fully vectorized in this specific case), but in some other also do nothing and simply does 'ret' in the function. As a bonus: ``` void fffff(immutable(float[4]) x, float[4] o) { o[2] = x[1] + x[3]; } import std.stdio : writeln; void main() { immutable(float[4]) k = [7.0f, 5.3f, 1.2f, 3.2f]; float[4] o; fffff(k, o); writeln(o); } ``` prints '[nan, nan, nan, nan]', but it should: '[nan, nan, 8.5, nan]'. I got the same results using my local gdc version 10.1.0 on amd64.