This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Error: Module array ... cannot be automatic or assumed shape



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]