This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Error: Module array ... cannot be automatic or assumed shape
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: Jonathan Dursi <ljdursi at cita dot utoronto dot ca>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, Mike Zingale <mzingale at scotty dot ess dot sunysb dot edu>
- Date: Wed, 1 Feb 2006 23:00:28 -0500
- Subject: Re: Error: Module array ... cannot be automatic or assumed shape
- References: <20060202034317.GA28142@cita.utoronto.ca>
On Feb 1, 2006, at 10:43 PM, Jonathan Dursi wrote:
In particular, this compiles:
program foo
integer, parameter :: len = 5
integer :: arr(max(len,1))
end
Well that is no question legal code as arr here is
either an automatic array or an array with constant size.
wheras changing `program' to `module':
module foo
integer, parameter :: len = 5
integer :: arr(max(len,1))
end
This is legal as "max(len,1)" is an initialization expression
as max is a "elemental standard intrinsic function" and every
argument is a constant.
I had to look this up in the standard to make sure.
Can either one of you file a bug as this still happens on the mainline?
Note a work around is to declare a named constant like:
module foo
integer, parameter :: len = 5
integer, parameter :: a = max(len,1)
integer :: array(a)
end
I think I know what is going on, we are not resolving the shape before
checking if it is a constant.
Thanks,
Andrew Pinski