Re: bug in g95 with character arrays?



glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:

My first thought is that it should work for a DATA statement,
but now I am not even sure about that.

Depends what your referent is for "it". If you are referring to an array
constructor whose elements have different character lengths, then the
answer is twofold

1. Such array constructors are not allowed in the first place. Period.
Context is irrelevant.

2. Data statement values are required to be scalar anyway, so they can't
be array constructors, regardless of whether the array constructor is
valid or not.

If you are talking about character values in data statements having
different character length, then

1. There is no relationship among the different values in a data
statement, so there is no particular restriction on the
non-relationship. Each value is related only to its corresponding
data-statement-object.

2. Intrinsic conversion is allowed, so yes, that allows the character
lengths in the values to be diferent from the character length of the
data-statement object. That's also true of the other syntax of
initialization, by the way. The restriction in question relates only to
array constructors, independent of context. The array constructor
doesn't have to agree in character length with the variable being
initialized; it just has to be a valid array constructor in the first
place, with *SOME* well-defined length.

One might think that PARAMETER was different, but it
seems that it isn't.

One wouldn't think that if one realized that an array constructor is an
array constructor and is independent of context, like pretty much
everything else in expressions. *SURELY* you are aware of that kind of
issue in regards to precision; in fact, it is practically the same
issue, insomuch as kind and length are both type parameters.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: Scope of implied-do index
    ... in a DATA statement or an array constructor has the scope of the implied-DO list. ... It is a scalar variable that has the type and type parameters that it would have if it were the name of a variable in the scoping unit that includes the DATA statement or array constructor, and this type shall be integer type." ... Aside from the fact that they're not included in the above quote, consider section 14.7.5, which includes "Beginning of execution of the action specified by an implied-DO list in an input/output statement causes the ... section 9.4.2 requires that the variable for an i/o implied-do be a scalar variable; this restriction is not there for array-constructor or data implied-do loops. ...
    (comp.lang.fortran)
  • Re: Scope of implied-do index
    ... in a DATA statement or an array constructor has the scope of the implied-DO list. ... It is a scalar variable that has the type and type parameters that it would have if it were the name of a variable in the scoping unit that includes the DATA statement or array constructor, and this type shall be integer type." ...
    (comp.lang.fortran)