Silverfrost Forums

Welcome to our forums

Illegal use of whole of assumed size arrays

10 Dec 2012 9:58 (Edited: 11 Dec 2012 7:04) #11267

In the code below, the reference to maxval with assumed size array a as an argument should be detected as an error at compile time.

module mmm
contains
function largest(a)
   real largest
   real, intent(in) :: a(*)  ! a is assumed size
   largest = maxval(a)     ! This should be detected as an error at compile time
end function largest
end module mmm

program anon
   use mmm
   real a(5), y
   a = (/(real(i),i=1,5)/)
   y = largest(a)
   print *, y
end program anon
11 Dec 2012 8:11 #11273

Thanks. I will log this as a bug.

21 Dec 2012 11:20 #11333

One think to note when you come to look at this, is that this will also affect dummy array arguments with the last dimension declared as 1 when /OLD_ARRAYS is switched on.

e.g.

subroutine xxx(a, b, n)
   integer n
   real a(1), b(n,1) !< extent of last dimension not known with /OLD_ARRAYS
end

should be treated as equivalent to the following when /OLD_ARRAYS is active,

subroutine xxx(a, b, n)
   integer n
   real a(*), b(n,*) !< extent of last dimension not known
end
22 Dec 2012 7:56 #11334

Thanks for this.

8 Apr 2013 1:16 #11995

This bug has been fixed for the next release.

9 Apr 2013 4:36 #12009

Thanks Paul.

Please login to reply.