Depending on compiler options the following codes show different reactions (sometimes with hanging process). Depending on environment settings too (e.g. $LANG, $LC_ALL). All suffer from a negative substring-range (length < -1). $ cat z1.f90 program p character(100) :: x data x(998:99) /'ab'/ end $ cat z2.f90 program p character(2) :: x data x(:-1) /'ab'/ end $ gfortran -c z1.f90 z1.f90:3:20: data x(998:99) /'ab'/ 1 Warning: Initialization string starting at (1) was truncated to fit the variable (-898/2) f951: internal compiler error: Segmentation fault $ gfortran -c z2.f90 z2.f90:3:17: data x(:-1) /'ab'/ 1 Warning: Initialization string starting at (1) was truncated to fit the variable (-1/2) *** Error in `/usr/lib64/gcc/x86_64-suse-linux/5/f951': malloc(): memory corruption (fast): 0x0000000001c03420 *** $ gfortran -g -O0 -Wall -fcheck=all -fno-frontend-optimize -c z2.f90 z2.f90:3:17: data x(:-1) /'ab'/ 1 Warning: Initialization string starting at (1) was truncated to fit the variable (-1/2) *** Error in `/usr/lib64/gcc/x86_64-suse-linux/5/f951': corrupted double-linked list: 0x00000000036d5db0 ***
$ echo $LANG de_DE.UTF-8 $ echo $LC_ALL $ cat z3.f90 program p character(8) :: x data x(3:1) /'abc'/ end $ gfortran -g -O0 z3.f90 z3.f90:3:17: data x(3:1) /'abc'/ 1 Warning: Initialization string starting at (1) was truncated to fit the variable (-1/3) f951: malloc.c:2369: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct ...
On x86_64-apple-darwin14, the tests mostly hang after the warning from 4.8 up to trunk (6.0).
I'm testing a patch.
Author: kargl Date: Wed Oct 21 21:40:05 2015 New Revision: 229153 URL: https://gcc.gnu.org/viewcvs?rev=229153&root=gcc&view=rev Log: 2015-10-21 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/67939 * data.c (create_character_initializer): Deal with zero length string. 2015-10-21 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/67939 * gfortran.dg/pr67939.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/pr67939.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/data.c trunk/gcc/testsuite/ChangeLog
Author: kargl Date: Thu Oct 29 20:07:13 2015 New Revision: 229555 URL: https://gcc.gnu.org/viewcvs?rev=229555&root=gcc&view=rev Log: 2015-10-29 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/67939 * data.c (create_character_initializer): Deal with zero length string. 2015-10-29 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/67939 * gfortran.dg/pr67939.f90: New test. Added: branches/gcc-5-branch/gcc/testsuite/gfortran.dg/pr67939.f90 Modified: branches/gcc-5-branch/gcc/fortran/ChangeLog branches/gcc-5-branch/gcc/fortran/data.c branches/gcc-5-branch/gcc/testsuite/ChangeLog
Fixed on trunk and 5-branch. Thanks for bug report.