I encountered this strange warning that is suppressed by a WRITE statement:
D:\gfortran>type warning.f90
module funcs
use ISO_FORTRAN_ENV
implicit none
integer, parameter :: wp = REAL64
contains
function identity(n)
integer, intent(in) :: n
real(wp) identity(n,n)
integer i
identity = 0
do i = 1, n
identity(i,i) = 1
end do
end function identity
end module funcs
program main
use funcs
implicit none
real(wp), allocatable :: A(:,:)
! write(*,*) 'This suppresses the warning.'
A = identity(8)
end program main
D:\gfortran>gfortran -Wall warning.f90 -owarni
ng
warning.f90:24:0:
A = identity(8)
Warning: 'a.offset' is used uninitialized in this function
[-Wuninitialized]
warning.f90:24:0: Warning: 'a.dim[0].lbound' is used uninitialized in
this funct
ion [-Wuninitialized]
warning.f90:24:0: Warning: 'a.dim[0].ubound' is used uninitialized in
this funct
ion [-Wuninitialized]
warning.f90:24:0: Warning: 'a.dim[1].lbound' is used uninitialized in
this funct
ion [-Wuninitialized]
warning.f90:24:0: Warning: 'a.dim[1].ubound' is used uninitialized in
this funct
ion [-Wuninitialized]
warning.f90:24:0:
A = identity(8)
Warning: 'a.dim[0].lbound' may be used uninitialized in this function [-Wmaybe-u
ninitialized]
warning.f90:24:0: Warning: 'a.dim[0].ubound' may be used uninitialized
in this f
unction [-Wmaybe-uninitialized]
warning.f90:24:0: Warning: 'a.dim[1].lbound' may be used uninitialized
in this f
unction [-Wmaybe-uninitialized]
warning.f90:24:0: Warning: 'a.dim[1].ubound' may be used uninitialized
in this f
unction [-Wmaybe-uninitialized]
warning.f90:24:0: Warning: 'a.dim[0].ubound' may be used uninitialized
in this f
unction [-Wmaybe-uninitialized]
warning.f90:24:0: Warning: 'a.dim[0].lbound' may be used uninitialized
in this f
unction [-Wmaybe-uninitialized]
warning.f90:24:0: Warning: 'a.dim[1].ubound' may be used uninitialized
in this f
unction [-Wmaybe-uninitialized]
warning.f90:24:0: Warning: 'a.dim[1].lbound' may be used uninitialized
in this f
unction [-Wmaybe-uninitialized]
I encountered this strange warning that is suppressed by a WRITE statement:
On Sunday, April 3, 2022 at 3:34:14 AM UTC-7, James Van Buskirk wrote:
I encountered this strange warning that is suppressed by a WRITE statement:Seems to be a Heisenbug:
https://en.wikipedia.org/wiki/Heisenbug
On Tuesday, April 5, 2022 at 7:23:43 AM UTC+12, gah4 wrote:jfh wrote:
On Sunday, April 3, 2022 at 3:34:14 AM UTC-7, James Van Buskirk wrote:
I encountered this strange warning that is suppressed by a WRITE statement:Seems to be a Heisenbug:
https://en.wikipedia.org/wiki/Heisenbug
With my gfortran in an x86_64 Linux system about which gfortran -v said among many other things
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) there was no warning message. Perhaps it's a Gatesbug: James's D:\ makes me suspect that he was using Microsoft.
On Tuesday, April 5, 2022 at 7:23:43 AM UTC+12, gah4 wrote:
On Sunday, April 3, 2022 at 3:34:14 AM UTC-7, James Van Buskirk wrote:
I encountered this strange warning that is suppressed by a WRITE statement:Seems to be a Heisenbug:
https://en.wikipedia.org/wiki/Heisenbug
With my gfortran in an x86_64 Linux system about which gfortran -v said among many other things
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) there was no warning message. Perhaps it's a Gatesbug: James's D:\ makes me suspect that he was using Microsoft.
It's a gfortran bug that can be ignored (unless one of the participants here wants to fix it).
If one is leary of ignoring such a dire warning, then add -fno-realloc-lhs to you
command line or allocate the array to zero size before using it on the left hand
side.
I wasn't sure if the OP was noting the warning, or that it goes away with
the print statement. The latter is what makes a Heisenbug.
"gah4" wrote in message news:03035c65-dbd8-4e4d-a0fb-1cba4549a649n@googlegroups.com...
I wasn't sure if the OP was noting the warning, or that it goes away with
the print statement. The latter is what makes a Heisenbug.
The first thing I tried was allocating the array to zero size, but then
I noticed that other arrays that weren't so preallocated didn't
present this issue. I tried a few other commands to see whether
any of them suppressed the warning and found the WRITE did
the trick.
Thanks to sgk for his thorough analysis. It's bugs like this one
that make me wonder about how many latent bugs must be
present in any notrivial software package.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 99:14:18 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,783 |