This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/85521] [8 Regression] ICE in gfc_resolve_character_array_constructor, at fortran/array.c:2049
- From: "kargl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 25 Apr 2018 00:35:18 +0000
- Subject: [Bug fortran/85521] [8 Regression] ICE in gfc_resolve_character_array_constructor, at fortran/array.c:2049
- Auto-submitted: auto-generated
- References: <bug-85521-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85521
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #4 from kargl at gcc dot gnu.org ---
gfc_resolve_character_array_constructor in array.c is not prepared
for a clever user who causes a zero length component by purposely
reference a string with an upper bound less than the lower bound.
This fixes the problem by setting a negative length to zero.
Index: gcc/fortran/array.c
===================================================================
--- gcc/fortran/array.c (revision 259623)
+++ gcc/fortran/array.c (working copy)
@@ -2046,7 +2046,8 @@ got_charlen:
else
return true;
- gcc_assert (current_length != -1);
+ if (current_length < 0)
+ current_length = 0;
if (found_length == -1)
found_length = current_length;