Fortran: fix ICE in get_expr_storage_size [PR108421]

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

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.



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