https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97571
--- Comment #6 from anlauf at gcc dot gnu.org --- (In reply to Mark J Olah from comment #5) > Whatever is happening inside the AST evaluation in this case is not only > extraordinarily inefficient, but also apparently exponential with the size > of the fixed array. This can be demonstrated by adjusting N in the test > case I added to bug #100235. You are asking for the evaluation of a constant expression, and the compiler does it. > A quick test shows I can compute ACOS of 10^8 elements in less than a second > on any reasonable hardware. We are talking about only 32k elements here, > which should be trivial. If you want run-time evaluation of acos, you get it when you write your code this way. If not, e.g. change it so that it looks to the compiler that one of the bounds is non-constant. The code in comment#0 e.g. could read: subroutine bpr_init implicit none integer :: i real :: tacos2( 0:35250) integer :: n = 99250 tacos2 = acos( (/ (i, i=64000,n) /) / 100000.0) end subroutine bpr_init You'll then get even more compact and probably efficient code than in older versions of gfortran, because it will no longer generate the unused data array as explained by Steve. > In any case is there a flag I can add to the compiler to disable this new > behavior? Currently no. The gfortran change was done to allow the r.h.s. expression to evaluate at compile time so that it can be used e.g. in parameter statements, which is required by the standard. One could envision checking the l.h.s. and decide to not do the simplification of the r.h.s. in case of assignments. Somebody would need to implement that. To me it looks like: doctor, it hurts when I do ... As a workaround, see my suggestion above.