https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106684

            Bug ID: 106684
           Summary: inconsistent array initialization
           Product: gcc
           Version: 10.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: j...@bolding-bruggeman.com
  Target Milestone: ---

The minor update of 10.3 to 10.4 causes gfortran to no longer accept
initialization of multidimensional array components with 1d data. However,
standalone multidimensional arrays can still be initialized with 1d data. That
seems inconsistent. The same behavior is found in recent releases of 11 and 12
(tested: 11.3.0, 12.1.0)

Example:

program p
   implicit none

   real :: a(2,2)
   data a /0., 1., 2., 3./

   type t
      integer :: b
      real :: a(2,2)
   end type
   type (t) c
   data c /t(1, (/0., 1., 2., 3./))/
end program

This results in the following error with gfortran 10.4:

test_array_init.F90:12:16:

   12 |    data c /t(1, (/0., 1., 2., 3./))/
      |                1
Error: The rank of the element in the structure constructor at (1) does not
match that of the component (1/2)

However, the above code is accepted by gfortran 9.x and 10.3, as well as ifort.

Reply via email to