[Bug fortran/114626] Very long time for compilation the attached program, depends on value of a parameter

2024-04-08 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114626

--- Comment #3 from anlauf at gcc dot gnu.org ---
Another option is to not declare max_sum as parameter but as variable.
With

integer  :: max_sum = 2 * max_ij ** 3

the code compiles almost instantly, but it has noticeable runtime.

(But it performs much better here than with Intel... :)

[Bug fortran/114626] Very long time for compilation the attached program, depends on value of a parameter

2024-04-08 Thread arjen.markus895 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114626

--- Comment #2 from Arjen Markus  ---
Thanks for the explanation - that is clear enough.

[Bug fortran/114626] Very long time for compilation the attached program, depends on value of a parameter

2024-04-07 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114626

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=97571
   Priority|P3  |P4

--- Comment #1 from anlauf at gcc dot gnu.org ---
Note that

pack( [ (k, k = 1,max_sum)], &
[ ( count( [((i**3+j**3, i = 1,j), j = 1,max_ij)] == k ) > 1, k = 1,max_sum )]
)

is a constant expression that the frontend tries to simplify at compile time.
I assume that most of the time goes into handling of the array constructors.

There's no limit implemented that checks the complexity of such expressions
and to give up if that limit is reached.

An expression like the above could occur in a parameter definition, and a
limit then might terminate the compilation with an error.

Fortunately, you've already found a workaround.

For a related PR see pr97571.