http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46979
Summary: Possible false "may be used uninitialized in this
function" warning
Product: gcc
Version: 4.4.5
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: fortran
AssignedTo: [email protected]
ReportedBy: [email protected]
$ cat foo.f90
integer function foo(symbol) result(Z)
! Given a two character element symbol, it will return its Z number
implicit none
character(2),intent(in) :: symbol
select case ( symbol )
case ("H ")
Z = 1
case default
Z = 0
end select
end function foo
$ gfortran -c -Wall -O3 foo.f90
foo.f90: In function ‘foo’:
foo.f90:2: warning: ‘z’ may be used uninitialized in this function
$ gfortran -v -c -Wall -O3 foo.f90
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.4.5/configure --enable-languages=c,c++,fortran
--prefix=/server-home/mjw/code/gcc/4.4.5
Thread model: posix
gcc version 4.4.5 (GCC)
COLLECT_GCC_OPTIONS='-v' '-c' '-Wall' '-O3' '-mtune=generic'
/server-home/mjw/code/gcc/4.4.5/libexec/gcc/x86_64-unknown-linux-gnu/4.4.5/f951
foo.f90 -quiet -dumpbase foo.f90 -mtune=generic -auxbase foo -O3 -Wall -version
-fintrinsic-modules-path
/server-home/mjw/code/gcc/4.4.5/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/finclude
-o /tmp/ccrtJDG2.s
GNU Fortran (GCC) version 4.4.5 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.4.5, GMP version 4.1.4, MPFR version 2.3.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
foo.f90: In function ‘foo’:
foo.f90:2: warning: ‘z’ may be used uninitialized in this function
COLLECT_GCC_OPTIONS='-v' '-c' '-Wall' '-O3' '-mtune=generic'
as -V -Qy -o foo.o /tmp/ccrtJDG2.s
GNU assembler version 2.15.92.0.2 (x86_64-redhat-linux) using BFD version
2.15.92.0.2 20040927
COMPILER_PATH=/server-home/mjw/code/gcc/4.4.5/libexec/gcc/x86_64-unknown-linux-gnu/4.4.5/:/server-home/mjw/code/gcc/4.4.5/libexec/gcc/x86_64-unknown-linux-gnu/4.4.5/:/server-home/mjw/code/gcc/4.4.5/libexec/gcc/x86_64-unknown-linux-gnu/:/server-home/mjw/code/gcc/4.4.5/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/:/server-home/mjw/code/gcc/4.4.5/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/server-home/mjw/code/gcc/4.4.5/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/:/server-home/mjw/code/gcc/4.4.5/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/intel/mkl/10.1.1.019/lib/em64t/:/server-home/netbin/intel/Compiler/11.1/069/lib/intel64/:/server-home/netbin/intel/Compiler/11.1/069/mkl/lib/em64t/:/server-home/netbin/intel/Compiler/11.1/069/lib/intel64/:/server-home/netbin/intel/Compiler/11.1/069/mkl/lib/em64t/:/server-home/mjw/code/gcc/4.4.5/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-c' '-Wall' '-O3' '-mtune=generic'
Warning seems to only manifest when when using -O{1,2,3}. Also, warning at -O3
will disappear if the Z = 1 is commented out.