Yes, the -Wuninitialized
option of gfortran produces so many false positives that it should usually be turned off, especially if you use the allocation-on-assignment feature of Fortran. For example, for the code
implicit none
integer, allocatable :: v(:)
v = [10,20]
print*,v
end
you get
c:\fortran\test>gfortran -Wall -Wextra xgfortran_warn.f90
xgfortran_warn.f90:3:11:
3 | v = [10,20]
| ^
Warning: 'v.offset' is used uninitialized [-Wuninitialized]
xgfortran_warn.f90:2:28:
2 | integer, allocatable :: v(:)
| ^
note: 'v' declared here
xgfortran_warn.f90:3:11:
3 | v = [10,20]
| ^
Warning: 'v.dim[0].lbound' is used uninitialized [-Wuninitialized]
xgfortran_warn.f90:2:28:
2 | integer, allocatable :: v(:)
| ^
note: 'v' declared here
xgfortran_warn.f90:3:11:
3 | v = [10,20]
| ^
Warning: 'v.dim[0].ubound' is used uninitialized [-Wuninitialized]
xgfortran_warn.f90:2:28:
2 | integer, allocatable :: v(:)
| ^
note: 'v' declared here
xgfortran_warn.f90:3:11:
3 | v = [10,20]
| ^
Warning: 'v.dim[0].lbound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:2:28:
2 | integer, allocatable :: v(:)
| ^
note: 'v' declared here
xgfortran_warn.f90:3:11:
3 | v = [10,20]
| ^
Warning: 'v.dim[0].ubound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:2:28:
2 | integer, allocatable :: v(:)
| ^
note: 'v' declared here
xgfortran_warn.f90:3:11:
3 | v = [10,20]
| ^
Warning: 'v.dim[0].ubound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:2:28:
2 | integer, allocatable :: v(:)
| ^
note: 'v' declared here
xgfortran_warn.f90:3:11:
3 | v = [10,20]
| ^
Warning: 'v.dim[0].lbound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:2:28:
2 | integer, allocatable :: v(:)
| ^
note: 'v' declared here
for gfortran 12.0.1 20220213.
gfortran -Wall -Wextra -Wno-uninitialized xgfortran_warn.f90
is appropriately silent.