[PATCH] PR fortran/67987 -- character lengths cannot be negative
FX
fxcoudert@gmail.com
Fri Oct 16 20:17:00 GMT 2015
> The attach patch enforces the Fortran Standard's requirement
> that character length must be great than or equal to zero.
We've got to be careful about this. The standard (F2008) has this to say about character lengths:
4.4.3.1. "The number of characters in the string is called the length of the string. The length is a type parameter; its kind is processor dependent and its value is greater than or equal to zero.”
but
4.4.3.2. "If the character length parameter value evaluates to a negative value, the length of character entities declared is zero."
So while strings cannot have negative length, they can be declared with a length parameter value which is itself negative, leading to the string having zero length. Or, said otherwise:
character(len=-2) :: s
is legal and declares a string of zero length, being thus equivalent to:
character(len=0) :: s
Thus: not OK to commit.
FX
More information about the Fortran
mailing list