[PATCH] PR fortran/67987 -- character lengths cannot be negative

Steve Kargl sgk@troutmask.apl.washington.edu
Fri Oct 16 19:08:00 GMT 2015


The attach patch enforces the Fortran Standard's requirement
that character length must be great than or equal to zero.
The fix submitted here supercedes the fix for PR fortran/31250,
which silently converted a negative string length to zero.
In removing the fix for 31250, a regression occurred, because
a substring reference where the 'start' value is larger than 
'end' value results in a zero length string.  gfortran was computing
the length, but not checking for a negative value.  This has
be fixed by actually doing the check and resetting legnth to
zero. 

Built and tested on x86_64-*-freebsd.  OK to commit? 

2015-10-16  Steven G. Kargl  <kargl@gcc.gnu.org>

	* decl.c (char_len_param_value): Check for negative character length.
	Unwrap a nearby unlong line.
	* resolve.c (gfc_resolve_substring_charlen): If a substring would have
	a negative character length, set it to zero per the Fortran standard.
	Unwrap a nearby unlong line.
	(resolve_charlen): Check for negative character length.

2015-10-16  Steven G. Kargl  <kargl@gcc.gnu.org>

	gfortran.dg/char_length_2.f90: Update the testcase.

-- 
Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr67987.diff
Type: text/x-diff
Size: 5113 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20151016/e08e106d/attachment.bin>


More information about the Fortran mailing list