Welcome to the forum!
I take it that your “iterate” case is the one with the implied do-loop (buildarray = …)? Aha, yes, the titles to your timings seem to say so ![]()
While I am not a compiler writer, I can make a guess at the timings: in the second case the program needs to make a temporary array, fill it and then copy it into the target array on the lefthand-side. But since this can be done at compile-time, you probably have a case where the compiler does the heavy work and stores the result in the object file (.o).
Is there a difference in size between the object files you get?
Note: I once wrote a program where just about all compilation could be done by simply filling a data array at compile time. For one compiler I tried, this took ages and only when I reduced the size was my amount of patience later than the burden on that compiler. (Just for your information: it was a program that determined Ramanujan numbers up to 1 million in a single statement)