Infamous PR fortran/19925
Steve Kargl
sgk@troutmask.apl.washington.edu
Sun Sep 14 05:17:00 GMT 2008
Well, I spent some time last week thinking about PR
fortran/19925 and have decided that the best option
may be to punt. Consider the somewhat far fetched
but legal Fortran,
program test
implicit none
integer j
integer, parameter :: n = 1000000
integer, parameter :: i(n) = (/ (2*j, j = 1, n) /)
real :: x(i(5))
do j = 1, i(5)
x(j) = sin(i(j) * 1.23)
end do
print *, x
end program test
Most possible solutions that I could fathom would inhibit
the optimizer from possibly optimizing the above loop.
So, I've come up with the following patch. It does not
fix the compile time problem, the memory consumption
problem during compilation, nor the size of an object file.
It simply gives a user a method (or more appropriately a
gun) to shoot their feet if they do something like the above.
The above code will not compile with gfortran. With my
patch, one can do
gfortran -fmax-array-construct=1000000 test.f90
If the gfortran maintainers prefer a better solution, then I'll
certainly won't be offended.
2008-09-13 Steven G. Kargl <kargls@comcast.net>
PR fortran/19925
* trans-array.c (gfc_trans_array_constructor_value): Replace an
internal_error with gfc_error_now.
* array.c: Remove GFC_MAX_AC_EXPAND
(gfc_expand_constructor): Use gfc_option.flag_max_array_constructor.
* gfortran.h: Add flag_max_array_constructor
* lang.opt: Add -fmax-array-constructor option.
* invoke.texi: Document option.
* options.c (gfc_init_options): Set
gfc_option.flag_max_array_constructor
(gfc_handle_option): Process option.
--
Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr19925.diff
Type: text/x-diff
Size: 5881 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080914/96691bb1/attachment.bin>
More information about the Fortran
mailing list