[Bug fortran/106684] inconsistent array initialization

jorn@bolding-bruggeman.com gcc-bugzilla@gcc.gnu.org
Fri Aug 19 19:16:21 GMT 2022


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

--- Comment #5 from Jorn Bruggeman <jorn@bolding-bruggeman.com> ---
Thanks; it does look like older gfortran versions (and ifort) are too forgiving
here, and that, given the F2018 definition of "conformable", the latest
gfortran releases are correct.

As for "stand-alone" variables, I just means regular variables (i.e., not a
component of a derived type). What surprised me is that this still compiles
fine in latest gfortran versions:

program p
   implicit none

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

with the data assigned to "a" seemingly being of rank 1. However, this seems to
work because the rules governing "data" statements for arrays explicitly
describe the target elements ("a") being unpacked in array order, and the total
number of values having to match.

Conversely, this is [correctly] rejected by the latest gfortran versions:

program p
   implicit none

   real :: a(2,2) = (/0., 1., 2., 3./)
end program

All in all, I accept this change in 10.4 and 11.3 was not a bug but an
improvement. It unfortunately does mean that the code (not my own, but one I
depend on) will need changes in >100 places...


More information about the Gcc-bugs mailing list