public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "tkoenig at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/94578] Incorrect assignment of RESHAPE() result to a Fortran pointer Date: Fri, 17 Apr 2020 15:17:19 +0000 [thread overview] Message-ID: <bug-94578-4-KYAMOcpldE@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94578-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94578 --- Comment #9 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- Here's what a solution could look like. I am not really sure that this is the way to go, there may be some corner cases (pointer to an argument which was passed as a transposed argument?) which this might get wrong. diff --git a/libgfortran/generated/maxval_i4.c b/libgfortran/generated/maxval_i4.c index abad45b50ae..3a9ed436956 100644 --- a/libgfortran/generated/maxval_i4.c +++ b/libgfortran/generated/maxval_i4.c @@ -50,6 +50,7 @@ maxval_i4 (gfc_array_i4 * const restrict retarray, index_type delta; index_type dim; int continue_loop; + int ret_factor; /* Make dim zero based to avoid confusion. */ rank = GFC_DESCRIPTOR_RANK (array) - 1; @@ -112,6 +113,7 @@ maxval_i4 (gfc_array_i4 * const restrict retarray, return; } + ret_factor = 1; } else { @@ -124,12 +126,16 @@ maxval_i4 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) bounds_ifunction_return ((array_t *) retarray, extent, "return value", "MAXVAL"); + if (retarray->span != 0) + ret_factor = retarray->span / sizeof(GFC_INTEGER_4); + else + ret_factor = 1; } for (n = 0; n < rank; n++) { count[n] = 0; - dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n); + dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n) * ret_factor; if (extent[n] <= 0) return; }
next prev parent reply other threads:[~2020-04-17 15:17 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-13 13:46 [Bug fortran/94578] New: " howisjw at hotmail dot com 2020-04-13 13:53 ` [Bug fortran/94578] " howisjw at hotmail dot com 2020-04-13 13:56 ` howisjw at hotmail dot com 2020-04-14 15:05 ` tkoenig at gcc dot gnu.org 2020-04-14 15:08 ` tkoenig at gcc dot gnu.org 2020-04-16 14:21 ` tkoenig at gcc dot gnu.org 2020-04-16 14:24 ` tkoenig at gcc dot gnu.org 2020-04-17 7:02 ` howisjw at hotmail dot com 2020-04-17 14:16 ` tkoenig at gcc dot gnu.org 2020-04-17 15:17 ` tkoenig at gcc dot gnu.org [this message] 2020-04-25 10:29 ` cvs-commit at gcc dot gnu.org 2020-04-27 9:42 ` howisjw at hotmail dot com 2020-04-27 16:57 ` tkoenig 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-94578-4-KYAMOcpldE@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).