public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/52012] [4.6/4.7 Regression] Wrong-code with realloc on assignment and RESHAPE w/ ORDER= Date: Fri, 27 Jan 2012 10:06:00 -0000 [thread overview] Message-ID: <bug-52012-4-ZphAiDNkzM@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-52012-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52012 Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|[4.6/4.7 Regression] |[4.6/4.7 Regression] |Wrong-code with realloc on |Wrong-code with realloc on |assignment |assignment and RESHAPE w/ | |ORDER= --- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-27 09:18:10 UTC --- Up and including the RESHAPE call, everything looks fine. However, one then updates the bounds as follows, which seems to fail. If one does not use RESHAPE with the ORDER= argument, it works that the "shape(a)" is used as argument to RESHAPE does not play a role. a.offset = 1; a.dim[0].lbound = 1; a.dim[0].ubound = a.dim[0].ubound + 1; a.offset = (a.dim[0].ubound - a.dim[0].lbound) + 1; a.dim[1].lbound = 1; a.dim[1].ubound = a.dim[1].ubound + 1; a.offset = (a.dim[1].ubound - a.dim[1].lbound) + 1; a.dim[2].lbound = 1; a.dim[2].ubound = a.dim[2].ubound + 1; a.offset = ~((a.dim[0].ubound - a.dim[0].lbound) + 1) + ~(a.dim[1].ubound - a.dim[1].lbound); * * * Additionally, the realloc on assignment may sets the wrong bounds if no (re)allocation is needed. From trans-expr.c's fcncall_realloc_result: /* Now reset the bounds from zero based to unity based. */ That's wrong. The lower bounds are remain the same, unless the RHS has a different shape. Then, the LHS is reallocated with a lower bound of lbound(RHS). Thus, one expects "7 9 / 1 3" for the program below, but gfortran has "1 3 / 1 3". Using for the RHS external functions, other expressions and variables correctly keep the bounds, if no realloc happens. integer, allocatable :: a(:), b(:) allocate(b(3)) b = [1,2,3] allocate (a(7:9)) a = reshape( b, shape=[size(b)]) print *, lbound(a), ubound(a) ! Expected: 7 9 deallocate (a) a = reshape( b, shape=[size(b)]) print *, lbound(a), ubound(a) ! Expected: 1 3 end
next prev parent reply other threads:[~2012-01-27 9:18 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-01-26 23:14 [Bug fortran/52012] New: [4.6/4.7 Regression] Wrong-code with RESHAPE burnus at gcc dot gnu.org 2012-01-27 0:13 ` [Bug fortran/52012] " burnus at gcc dot gnu.org 2012-01-27 0:22 ` dominiq at lps dot ens.fr 2012-01-27 0:26 ` [Bug fortran/52012] [4.6/4.7 Regression] Wrong-code with realloc on assignment burnus at gcc dot gnu.org 2012-01-27 9:27 ` rguenth at gcc dot gnu.org 2012-01-27 10:06 ` burnus at gcc dot gnu.org [this message] 2012-01-27 10:54 ` [Bug fortran/52012] [4.6/4.7 Regression] Wrong-code with realloc on assignment and RESHAPE w/ ORDER= jakub at gcc dot gnu.org 2012-01-30 22:21 ` pault at gcc dot gnu.org 2012-01-30 23:16 ` burnus at gcc dot gnu.org 2012-01-31 9:47 ` paul.richard.thomas at gmail dot com 2012-01-31 12:52 ` pault at gcc dot gnu.org 2012-01-31 12:56 ` [Bug fortran/52012] " pault at gcc dot gnu.org 2012-01-31 13:02 ` pault at gcc dot gnu.org 2012-01-31 14:32 ` [Bug fortran/52012] [4.6/4.7 Regression] " burnus at gcc dot gnu.org 2012-02-02 21:20 ` pault at gcc dot gnu.org 2012-02-03 18:35 ` pault at gcc dot gnu.org 2012-02-03 20:42 ` burnus at gcc dot gnu.org 2012-02-03 20:44 ` burnus 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-52012-4-ZphAiDNkzM@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).