Unassigned variable warning?

19 views
Skip to first unread message

Jim Green

unread,
Jun 27, 2017, 4:40:09 PM6/27/17
to GNU Fortran
Does gfortran have any compiler option to flag the "b = a" line below:

program Main
character(len=1) :: a,b
b = a
end program Main
Lahey Fortran produces "a is used but never set."  "-Wall" says nothing.

Using MinGW.

TIA.

Beliavsky

unread,
Jun 27, 2017, 4:46:43 PM6/27/17
to GNU Fortran
Try using -Wextra in addition to -Wall. 

For GNU Fortran (GCC) 8.0.0 20170430 (experimental) from Equation.com on Windows I get the following results
for the code you posted:

c:\fortran\test>gfortran -Wall -Wextra xxuninit.f90
xxuninit.f90:3:0:

 b = a
 
Warning: 'a[1]{lb: 1 sz: 1}' is used uninitialized in this function [-Wuninitialized]
Reply all
Reply to author
Forward
0 new messages