[Bug fortran/106089] New: false positives with -Wuninitialized for allocation on assignment
beliavsky at aol dot com
gcc-bugzilla@gcc.gnu.org
Sun Jun 26 11:21:49 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106089
Bug ID: 106089
Summary: false positives with -Wuninitialized for allocation on
assignment
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: beliavsky at aol dot com
Target Milestone: ---
For the code
implicit none
integer, allocatable :: v(:)
character(len=1), allocatable :: a(:)
a = ["a"]
print*, a
v = [10,20]
print*,v
end
gfortran -Wall -Wextra xgfortran_warn.f90
gives many incorrect warnings:
xgfortran_warn.f90:4:9:
4 | a = ["a"]
| ^
Warning: 'a.offset' is used uninitialized [-Wuninitialized]
xgfortran_warn.f90:3:37:
3 | character(len=1), allocatable :: a(:)
| ^
note: 'a' declared here
xgfortran_warn.f90:4:9:
4 | a = ["a"]
| ^
Warning: 'a.dim[0].lbound' is used uninitialized [-Wuninitialized]
xgfortran_warn.f90:3:37:
3 | character(len=1), allocatable :: a(:)
| ^
note: 'a' declared here
xgfortran_warn.f90:4:9:
4 | a = ["a"]
| ^
Warning: 'a.dim[0].ubound' is used uninitialized [-Wuninitialized]
xgfortran_warn.f90:3:37:
3 | character(len=1), allocatable :: a(:)
| ^
note: 'a' declared here
xgfortran_warn.f90:4:9:
4 | a = ["a"]
| ^
Warning: 'a.dim[0].lbound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:3:37:
3 | character(len=1), allocatable :: a(:)
| ^
note: 'a' declared here
xgfortran_warn.f90:4:9:
4 | a = ["a"]
| ^
Warning: 'a.dim[0].ubound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:3:37:
3 | character(len=1), allocatable :: a(:)
| ^
note: 'a' declared here
xgfortran_warn.f90:4:9:
4 | a = ["a"]
| ^
Warning: 'a.dim[0].ubound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:3:37:
3 | character(len=1), allocatable :: a(:)
| ^
note: 'a' declared here
xgfortran_warn.f90:4:9:
4 | a = ["a"]
| ^
Warning: 'a.dim[0].lbound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:3:37:
3 | character(len=1), allocatable :: a(:)
| ^
note: 'a' declared here
The output is the same for gfortran 12.0.1 20220213 on Windows from
equation.com
and gfortran-11 on WSL2. The code combines two codes from a Fortran Discourse
discussion
https://fortran-lang.discourse.group/t/gfortran-uninitialized-warnings/3838 .
More information about the Gcc-bugs
mailing list