[Bug fortran/51434] ICE with scalar init of an array parameter, used in DT default init with transfer

burnus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 25 13:29:00 GMT 2012


--- Comment #14 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-06-25 13:28:34 UTC ---
(In reply to comment #13)
> Is the following variant 
> valid?

Looks valid - and with other compilers it does compile and run. What works in
gfortran is the following, which yields a scalar RHS of "= 'a'":
  character :: y(5) = transfer('abced', s(1)%z)

While for s%z or s(:)%z or even s(1:1)%z, one gets a size-5 array on the RHS,
namely "=['a','a','a','a','a']" (or with 'abcde' the array
['a','b','c','d','e']). That case is ICEing in gfortran.

>From F2008, "13.7.168 TRANSFER (SOURCE, MOLD [, SIZE])":

"Result Characteristics. The result is of the same type and type parameters as
Case (i): If MOLD is a scalar and SIZE is absent, the result is a scalar.
Case (ii): If MOLD is an array and SIZE is absent, the result is an array and
of rank one. Its size is as small as possible such that its physical
representation is not shorter than that of SOURCE.
Case (iii): If SIZE is present, the result is an array of rank one and size

More information about the Gcc-bugs mailing list