Hi. the following testcase demonstrates warnings that can be irritating: % cat gfcbug112.f90 module gfcbug112 implicit none logical :: ll = .false. contains subroutine calc_W (N, M) integer, intent(in) :: N, M real :: T(N,M,M) ! Temporary array 1 real, allocatable :: W(:,:,:) ! Temporary array 2 if(ll) then allocate (W(N,M,M)) end if T=0 if(ll) then W = 0 deallocate (W) end if end subroutine calc_W end module gfcbug112 % gfc-trunk -c -Wall -O gfcbug112.f90 gfcbug112.f90: In function ‘calc_w’: gfcbug112.f90:5:0: warning: ‘w.dim[2].stride’ may be used uninitialized in this function [-Wuninitialized] One can get really many of these in large modules... Harald
This is the "standard" uninitialized warning for predicates. There are a few other bugs like this.
Confirmed.
Reconfirmed with GCC 11 and the output below. $ gcc -O2 -S -Wall pr47386.f90 pr47386.f90:9:35: 9 | real, allocatable :: W(:,:,:) ! Temporary array 2 | ^ Warning: ‘w.dim[1].stride’ may be used uninitialized in this function [-Wmaybe-uninitialized] pr47386.f90:18:12: 18 | W = 0 | ^ Warning: ‘w.dim[0].ubound’ may be used uninitialized in this function [-Wmaybe-uninitialized] pr47386.f90:9:35: 9 | real, allocatable :: W(:,:,:) ! Temporary array 2 | ^ Warning: ‘w.dim[2].ubound’ may be used uninitialized in this function [-Wmaybe-uninitialized] pr47386.f90:9:35: Warning: ‘w.offset’ may be used uninitialized in this function [-Wmaybe-uninitialized] pr47386.f90:9:35: Warning: ‘w.dim[2].stride’ may be used uninitialized in this function [-Wmaybe-uninitialized] pr47386.f90:9:35: Warning: ‘w.dim[1].ubound’ may be used uninitialized in this function [-Wmaybe-uninitialized]
Re-confirmed with GCC 12 and trunk. We diagnose a use of w.dim[1].ubound conditional on ubound.1 > 0 && ll == 0. I believe we're jump-threading if (ll) around the T = 0 stmt and then mixing up paths. -fno-thread-jumps fixes the thing.