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/96312] Reallocation on assignment uses undefined variables Date: Fri, 24 Jul 2020 16:55:34 +0000 [thread overview] Message-ID: <bug-96312-4-0U95og9HkJ@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-96312-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96312 Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=77504 CC| |dev-zero at gentoo dot org --- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- Slightly sanitized test case from the originating PR, by Tiziano Müller: $ cat moda.f90 module moda contains PURE SUBROUTINE funca(arr, sz) REAL, ALLOCATABLE, DIMENSION(:, :), INTENT(OUT) :: arr integer, intent(in) :: sz allocate(arr(sz, sz)) arr(:, :) = 0. END SUBROUTINE end module $ cat modb.f90 module modc use moda, only: funca contains PURE SUBROUTINE funcb(oarr) REAL, DIMENSION(:), INTENT(OUT) :: oarr REAL, ALLOCATABLE, DIMENSION(:, :) :: arr real, allocatable, dimension(:) :: tmp CALL funca(arr, ubound(oarr, 1)) tmp = matmul(transpose(arr),oarr) oarr = tmp*1. END SUBROUTINE funcb end module Compiled with -O1 -Wall, this yields $ gfortran -Wall -O1 -c moda.f90 modb.f90 modb.f90:8:0: 8 | oarr = MATMUL(TRANSPOSE(arr), oarr)*1. | Warning: '__var_1_matmul.dim[0].lbound' is used uninitialized in this function [-Wuninitialized] modb.f90:8:0: Warning: '__var_1_matmul.dim[0].ubound' is used uninitialized in this function [-Wuninitialized] Front-end optimization introduces an extra assignment statement here, this version also shows the warning: $ cat modc.f90 module modc use moda, only: funca contains PURE SUBROUTINE funcb(oarr) REAL, DIMENSION(:), INTENT(OUT) :: oarr REAL, ALLOCATABLE, DIMENSION(:, :) :: arr real, allocatable, dimension(:) :: tmp CALL funca(arr, ubound(oarr, 1)) tmp = matmul(transpose(arr), oarr) oarr = tmp*1. END SUBROUTINE funcb end module The warning seems to be correct: $ grep __var_1_matmul modb.f90.004t.original struct array01_real(kind=4) __var_1_matmul; __var_1_matmul.data = 0B; __var_1_matmul.dtype = {.elem_len=4, .rank=1, .type=3}; D.3969 = __var_1_matmul; D.3970 = (real(kind=4)[0:] * restrict) __var_1_matmul.data == 0B; __builtin_free ((void *) __var_1_matmul.data); __var_1_matmul.data = D.3969.data; D.3971 = ((__var_1_matmul.dim[0].lbound - D.3969.dim[0].lbound) - __var_1_matmul.dim[0].ubound) + D.3969.dim[0].ubound != 0; D.3973 = D.3972 ? 1 : __var_1_matmul.dim[0].lbound; __var_1_matmul.dim[0].lbound = D.3973; __var_1_matmul.dim[0].ubound = D.3969.dim[0].ubound + D.3973; __var_1_matmul.dim[0].stride = 1; __var_1_matmul.offset = D.3974; D.4003 = (real(kind=4)[0:] * restrict) __var_1_matmul.data; D.4004 = __var_1_matmul.offset; D.4005 = __var_1_matmul.dim[0].lbound; D.4006 = __var_1_matmul.dim[0].ubound; if ((real(kind=4)[0:] * restrict) __var_1_matmul.data != 0B) __builtin_free ((void *) __var_1_matmul.data); (real(kind=4)[0:] * restrict) __var_1_matmul.data = 0B; So, something seems to be wrong with reallocation on assignment here.
next prev parent reply other threads:[~2020-07-24 16:55 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-24 16:47 [Bug fortran/96312] New: " tkoenig at gcc dot gnu.org 2020-07-24 16:55 ` tkoenig at gcc dot gnu.org [this message] 2020-07-24 17:35 ` [Bug fortran/96312] [10/11 Regression] " tkoenig at gcc dot gnu.org 2020-07-24 17:35 ` tkoenig at gcc dot gnu.org 2020-07-24 17:51 ` tkoenig at gcc dot gnu.org 2020-07-24 18:18 ` dominiq at lps dot ens.fr 2020-07-25 8:59 ` tkoenig at gcc dot gnu.org 2020-07-25 9:18 ` tkoenig at gcc dot gnu.org 2020-08-08 15:01 ` pault at gcc dot gnu.org 2020-08-10 5:22 ` cvs-commit at gcc dot gnu.org 2020-08-11 7:53 ` cvs-commit at gcc dot gnu.org 2020-08-11 8:04 ` pault 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-96312-4-0U95og9HkJ@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).