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

--- Comment #8 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> The failures I looked at were becasue the constructors were using strings
> of different sizes. So my question was going to be what are the rules. 
> Are the strings suppose to get padded to the length of the character
> array element?
>
> All elements must be of the same size so I assume if the length is say six,
> you can not use "abc" in a constructor and one must use "abc   "
>
> I did not check all the failures, but at least one requires the -fbackslash
> and with the patch passes fine if I pad out the strings in the constructor.

From my copy of the F2015 draft:

4.8 Construction of array values

1 An array constructor constructs a rank-one array value from a sequence of
scalar values, array values, and implied DO loops.

R469 array-constructor is (/ ac-spec /)
                       or lbracket ac-spec rbracket
R470 ac-spec is type-spec ::
             or [type-spec ::] ac-value-list
R471 lbracket is [
R472 rbracket is ]
R473 ac-value is expr
              or ac-implied-do
R474 ac-implied-do is ( ac-value-list , ac-implied-do-control )
R475 ac-implied-do-control is [ integer-type-spec :: ]
                              ac-do-variable = scalar-int-expr , 
                              scalar-int-expr [ , scalar-int-expr ]
R476 ac-do-variable is do-variable
...
2 If type-spec is omitted, corresponding length type parameters of the
declared type of each ac-value expression shall have the same value; in
this case, the declared type and type parameters of the array constructor
are those of the ac-value expressions.
3 If type-spec appears, it specifies the declared type and type parameters of
the array constructor.  Each ac-value expression in the array-constructor
shall be compatible with intrinsic assignment to a variable of this type
and type parameters.  Each value is converted to the type and type
parameters of the array-constructor in accordance with the rules of
intrinsic assignment (7.2.1.3).

From (2), I think 

   call foo([sun, " & rain"], res)

in gfortran.dg/unlimited_polymorphic_1.f03 is invalid (" & rain" should be
replaced with " & rain ", note that compiling the test with -fcheck=all results
in

At line 113 of file
/opt/gcc/_clean/gcc/testsuite/gfortran.dg/unlimited_polymorphic_1.f03
Fortran runtime error: Pointer actual argument 'u2' is not associated

).

>From (3), the constructs such as [ CHARACTER(len=4) :: "foobar", "xyz" ] are
valid, "footer" being truncated to "food" and "xyz" padded to "xyz ".

Reply via email to