[Bug fortran/77504] [8/9/10/11 Regression] "is used uninitialized" with allocatable string and array constructors
dev-zero at gentoo dot org
gcc-bugzilla@gcc.gnu.org
Fri Jul 24 14:45:14 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77504
Tiziano Müller <dev-zero at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dev-zero at gentoo dot org
--- Comment #19 from Tiziano Müller <dev-zero at gentoo dot org> ---
I have yet another (more complicated) case, but this time not reproducible with
gcc-7.5, only with 9 and 10:
** snip: 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
*** end snip ***
*** snip: modb.f90 ***
module modb
use moda, only: funca
contains
PURE SUBROUTINE funcb(oarr)
REAL, DIMENSION(:), INTENT(OUT) :: oarr
REAL, ALLOCATABLE, DIMENSION(:, :) :: arr
oarr(:) = 0.0
CALL funca(arr, ubound(oarr, 1))
oarr = MATMUL(TRANSPOSE(arr), oarr)*1.
END SUBROUTINE funcb
end module
*** end snip ***
building with:
gfortran -O1 -Werror=uninitialized -c moda.f90
gfortran -O1 -Werror=uninitialized -c modb.f90
triggers:
*** snip: output ***
modb.f90:11:0:
11 | oarr = MATMUL(TRANSPOSE(arr), oarr)*1.
|
Error: ‘__var_1_matmul.dim[0].lbound’ is used uninitialized in this function
[-Werror=uninitialized]
modb.f90:11:0: Error: ‘__var_1_matmul.dim[0].ubound’ is used uninitialized in
this function [-Werror=uninitialized]
f951: some warnings being treated as errors
*** end snip ***
Removing either the `*1` at the end or the call to `transpose` makes the
warning/error go away. As does using `-O0`.
More information about the Gcc-bugs
mailing list