public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/106500] ICE on function as an argument to c_sizeof() Date: Wed, 07 Sep 2022 18:13:46 +0000 [thread overview] Message-ID: <bug-106500-4-cvHUbopafZ@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-106500-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106500 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Priority|P3 |P4 Last reconfirmed| |2022-09-07 --- Comment #3 from kargl at gcc dot gnu.org --- (In reply to G. Steinmetz from comment #2) > The following examples are presumably valid code, > don't use a function, nor alloc, but should be related : > > > $ cat z1.f90 > program p > use iso_c_binding > integer :: a(2) = 0 > print *, c_sizeof((a)) > print *, c_sizeof(2*a) > end > > > $ cat z2.f90 > program p > use iso_c_binding > character(1) :: a(2) = '0' > print *, c_sizeof((a)) > print *, c_sizeof(a) > end > The above testcases compile with this patch. diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc index bbdb5b392fc..f5fed223a23 100644 --- a/gcc/fortran/array.cc +++ b/gcc/fortran/array.cc @@ -2766,7 +2766,24 @@ gfc_find_array_ref (gfc_expr *e, bool allow_null) { gfc_ref *ref; - for (ref = e->ref; ref; ref = ref->next) + if (e->expr_type == EXPR_OP && !e->ref) + { + gfc_expr *op1, *op2; + op1 = e->value.op.op1; + op2 = e->value.op.op2; + if (!op2) + { + if (op1->rank == 0) + return NULL; + ref = op1->ref; + } + else + ref = op2->ref; + } + else + ref = e->ref; + + for (; ref; ref = ref->next) if (ref->type == REF_ARRAY && (ref->u.ar.type == AR_FULL || ref->u.ar.type == AR_SECTION)) break;
next prev parent reply other threads:[~2022-09-07 18:13 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-01 19:20 [Bug fortran/106500] New: ICE on invalid " kargl at gcc dot gnu.org 2022-08-01 19:47 ` [Bug fortran/106500] ICE on function as an " kargl at gcc dot gnu.org 2022-09-07 17:15 ` gscfq@t-online.de 2022-09-07 18:13 ` kargl at gcc dot gnu.org [this message] 2024-04-05 17:18 ` anlauf at gcc dot gnu.org 2024-04-08 19:03 ` anlauf at gcc dot gnu.org 2024-04-08 19:58 ` anlauf at gcc dot gnu.org 2024-04-10 17:04 ` cvs-commit at gcc dot gnu.org 2024-04-10 19:49 ` anlauf at gcc dot gnu.org
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=bug-106500-4-cvHUbopafZ@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).