http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54208

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org 2012-08-09 16:32:07 UTC ---
(In reply to comment #0)
> The following reproducer:
> 
> program testit
>   integer, parameter :: n=2
>   integer, dimension(1-min(n,2)/2:n) :: arr
>   integer, parameter :: i=ubound(arr,1)
>   write(6,*) i
> end program testit
> 
> fails to compile:
> 
> >gfortran  testit.F90
> testit.F90:4.33:
> 
>   integer, parameter :: i=ubound(arr,1)
>                                  1
> Error: Array 'arr' at (1) is a variable, which does not reduce to a constant
> expression
> 

I believe that this may be a duplicate of another bug report,
but don't have time to check.  This problem is present in all
versions of gfortran from at least 4.3.6 onward.  Oddly, if one
tries 4.2.5, the code compiles.  A workaround (and yes I know
changing a large code base may be a PITA) is

 program testit
   integer, parameter :: n=2, m=1-min(n,2)/2
   integer, dimension(m:n) :: arr
   integer, parameter :: i=ubound(arr,1)
   write(6,*) i
 end program testit

Reply via email to