public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10015] Fortran: ICE, OOM while calculating sizes of derived type array components Date: Fri, 30 Jul 2021 20:13:49 +0000 (GMT) [thread overview] Message-ID: <20210730201349.6CA95398A4B9@sourceware.org> (raw) https://gcc.gnu.org/g:fa9729e7d2ee69fa0b18c925aeb3c2750874a05b commit r10-10015-gfa9729e7d2ee69fa0b18c925aeb3c2750874a05b Author: Harald Anlauf <anlauf@gmx.de> Date: Wed Jul 21 18:54:00 2021 +0200 Fortran: ICE, OOM while calculating sizes of derived type array components gcc/fortran/ChangeLog: PR fortran/101514 * target-memory.c (gfc_interpret_derived): Size of array component of derived type can only be computed here for explicit shape. * trans-types.c (gfc_get_nodesc_array_type): Do not dereference NULL pointers. gcc/testsuite/ChangeLog: PR fortran/101514 * gfortran.dg/pr101514.f90: New test. (cherry picked from commit c2b15fe27e6a0e42b108111d51acce69628593b4) Diff: --- gcc/fortran/target-memory.c | 3 +++ gcc/fortran/trans-types.c | 4 ++-- gcc/testsuite/gfortran.dg/pr101514.f90 | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/target-memory.c b/gcc/fortran/target-memory.c index 7f209913028..a3ef392b5d7 100644 --- a/gcc/fortran/target-memory.c +++ b/gcc/fortran/target-memory.c @@ -534,6 +534,9 @@ gfc_interpret_derived (unsigned char *buffer, size_t buffer_size, gfc_expr *resu { int n; + if (cmp->as->type != AS_EXPLICIT) + return 0; + e->expr_type = EXPR_ARRAY; e->rank = cmp->as->rank; diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 68d903d47ae..24758ddadee 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -1618,7 +1618,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed, GFC_TYPE_ARRAY_STRIDE (type, n) = tmp; expr = as->lower[n]; - if (expr->expr_type == EXPR_CONSTANT) + if (expr && expr->expr_type == EXPR_CONSTANT) { tmp = gfc_conv_mpz_to_tree (expr->value.integer, gfc_index_integer_kind); @@ -1668,7 +1668,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed, for (n = as->rank; n < as->rank + as->corank; n++) { expr = as->lower[n]; - if (expr->expr_type == EXPR_CONSTANT) + if (expr && expr->expr_type == EXPR_CONSTANT) tmp = gfc_conv_mpz_to_tree (expr->value.integer, gfc_index_integer_kind); else diff --git a/gcc/testsuite/gfortran.dg/pr101514.f90 b/gcc/testsuite/gfortran.dg/pr101514.f90 new file mode 100644 index 00000000000..51fbf8a7e85 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr101514.f90 @@ -0,0 +1,35 @@ +! { dg-do compile } +! PR fortran/101514 - ICE: out of memory allocating ... bytes + +subroutine s + type t1 + integer :: a(..) ! { dg-error "must have an explicit shape" } + end type + type t2 + integer :: a(*) ! { dg-error "must have an explicit shape" } + end type + type t3 + integer :: a(:) ! { dg-error "must have an explicit shape" } + end type + type t4 + integer :: a(0:) ! { dg-error "must have an explicit shape" } + end type + type t5 + integer, allocatable :: a(:) + end type + type t6 + integer, pointer :: a(:) + end type + type(t1) :: a1 + type(t2) :: a2 + type(t3) :: a3 + type(t4) :: a4 + type(t5) :: a5 + type(t6) :: a6 + a1 = transfer(1, a1) + a2 = transfer(1, a2) + a3 = transfer(1, a3) + a4 = transfer(1, a4) + a5 = transfer(1, a5) + a6 = transfer(1, a6) +end
reply other threads:[~2021-07-30 20:13 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210730201349.6CA95398A4B9@sourceware.org \ --to=anlauf@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).