Bug 93251 - Valid code rejected: Shape of array depends on parameter array
Summary: Valid code rejected: Shape of array depends on parameter array
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 9.2.0
: P4 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-13 15:11 UTC by Martin Diehl
Modified: 2020-01-20 13:57 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 10.0
Known to fail: 7.5.0, 8.3.1, 9.2.1
Last reconfirmed:


Attachments
source code (180 bytes, text/plain)
2020-01-13 15:11 UTC, Martin Diehl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Diehl 2020-01-13 15:11:03 UTC
Created attachment 47647 [details]
source code

The following code for array parameters does not compile even though it seems valid (shape/size known at compile time)

program initialize_shape_parameter

  integer, parameter               :: x = 2
  integer, parameter, dimension(1) :: y = [2]
  
  real, dimension(x,x),       parameter :: &
       ok1 = reshape([1.,2.,3.,4.],shape(ok1))
       
  real, dimension(y(1),y(1)), parameter :: &
       ok2 = reshape([1.,2.,3.,4.],[y(1),y(1)])
       
  real, dimension(y(1),y(1)), parameter :: &
    not_ok = reshape([1.,2.,3.,4.],shape(not_ok))  !<== ERROR

end program initialize_shape_parameter

Error: PARAMETER ‘not_ok’ is used at (1) before its definition is complete
Comment 1 kargls 2020-01-13 19:42:16 UTC
Code compiles with trunk.  Fails with at leaset 7, 8, and 9.  Given the loss of gfortran developer(s), this is unlikely to get fixed in branches.
Comment 2 Martin Liška 2020-01-20 13:57:24 UTC
Fixed on trunk with r10-5607-gde89b5748d68b76b06e3beca4a956060afb79a3d.
Not planning to backport, let's close the issue.