This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/88328] ICE in resolve_tag_format, at fortran/io.c:1641
- 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: Mon, 03 Dec 2018 21:08:58 +0000
- Subject: [Bug fortran/88328] ICE in resolve_tag_format, at fortran/io.c:1641
- Auto-submitted: auto-generated
- References: <bug-88328-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88328
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-12-03
Ever confirmed|0 |1
--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to G. Steinmetz from comment #0)
> Affects versions down to at least gcc-5 :
>
>
> $ cat z1.f90
> program p
> character(3), parameter :: a(0) = [character(3)::]
> print a
> end
>
>
> $ gfortran-9-20181202 -c z1.f90
> f951: internal compiler error: Segmentation fault
> 0xb2ec9f crash_signal
> ../../gcc/toplev.c:326
> 0x63ddee resolve_tag_format
> ../../gcc/fortran/io.c:1641
I get
% gfcx -c a.f90
a.f90:3:10:
3 | print a
| 1
Error: FORMAT tag at (1) cannot be a zero-sized array
with this patch
Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c (revision 266710)
+++ gcc/fortran/io.c (working copy)
@@ -1636,6 +1636,12 @@ resolve_tag_format (gfc_expr *e)
gfc_expr *r;
gfc_char_t *dest, *src;
+ if (e->value.constructor == NULL)
+ {
+ gfc_error ("FORMAT tag at %C cannot be a zero-sized array");
+ return false;
+ }
+
n = 0;
c = gfc_constructor_first (e->value.constructor);
len = c->expr->value.character.length;
@@ -3231,12 +3237,17 @@ gfc_resolve_dt (gfc_dt *dt, locus *loc)
{
gfc_expr *e;
io_kind k;
+ locus loc_tmp;
/* This is set in any case. */
gcc_assert (dt->dt_io_kind);
k = dt->dt_io_kind->value.iokind;
+ loc_tmp = gfc_current_locus;
+ gfc_current_locus = *loc;
RESOLVE_TAG (&tag_format, dt->format_expr);
+ gfc_current_locus = loc_tmp;
+
RESOLVE_TAG (&tag_rec, dt->rec);
RESOLVE_TAG (&tag_spos, dt->pos);
RESOLVE_TAG (&tag_advance, dt->advance);