diff mbox series

Fortran: fix ICE in get_expr_storage_size [PR108421]

Message ID trinity-1a5ca55f-e1cb-417f-9f67-59b39c16bc64-1673901535696@3c-app-gmx-bs50
State New
Headers show
Series Fortran: fix ICE in get_expr_storage_size [PR108421] | expand

Commit Message

Harald Anlauf Jan. 16, 2023, 8:38 p.m. UTC
Dear all,

here's an obvious patch for an ICE-on-invalid where we missed
a check that we actually have an integer length before trying
to extract a usable value.

Regtested on x86_64-pc-linux-gnu.

I intend to commit it to mainline within the next 24h unless
there are comments.

Cheers,
Harald
diff mbox series

Patch

diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc
index c4f7faaf597..307082b048d 100644
--- a/gcc/fortran/interface.cc
+++ b/gcc/fortran/interface.cc
@@ -2858,6 +2858,7 @@  get_expr_storage_size (gfc_expr *e)
   if (e->ts.type == BT_CHARACTER)
     {
       if (e->ts.u.cl && e->ts.u.cl->length
+	  && e->ts.u.cl->length->ts.type == BT_INTEGER
           && e->ts.u.cl->length->expr_type == EXPR_CONSTANT)
 	strlen = mpz_get_si (e->ts.u.cl->length->value.integer);
       else if (e->expr_type == EXPR_CONSTANT