gfortran -c -Wall -O2 uninit.f90 uninit.f90: In function ‘sub’: uninit.f90:22:0: warning: ‘new.dim[0].ubound’ may be used uninitialized in this function [-Wmaybe-uninitialized] new = fun() ^ gfortran -c -Wall -O1 uninit.f90 without warning gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.8-20130509/configure --enable-languages=c,c++,fortran --with-cloog --prefix=/usr/local/gcc-4.8 Thread model: posix gcc version 4.8.1 20130509 (prerelease) (GCC)
Created attachment 30815 [details] uninit.f90
Confirmed with 4.8 and trunk. The bogus warning does not seem to appear with 4.7.3.
Slightly reduced test case: module m implicit none type series real,allocatable :: a(:) end type contains function fun() type(series),allocatable :: fun(:) allocate(fun(0)) end function subroutine sub type(series),allocatable :: new(:) integer :: j do j=1,2 new = fun() end do end subroutine end module
This is not a serious regression and so I have set it to P3. That said, it is a real bug and I am just now regtesting the fix. Assigning myself. Paul
Author: pault Date: Sun Dec 1 11:42:25 2013 New Revision: 205566 URL: http://gcc.gnu.org/viewcvs?rev=205566&root=gcc&view=rev Log: 2013-12-01 Paul Thomas <pault@gcc.gnu.org> PR fortran/58410 * trans-array.c (gfc_alloc_allocatable_for_assignment): Do not use the array bounds of an unallocated array but set its size to zero instead. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-array.c
Author: pault Date: Sun Jan 19 18:04:22 2014 New Revision: 206778 URL: http://gcc.gnu.org/viewcvs?rev=206778&root=gcc&view=rev Log: 2014-01-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/58410 * trans-array.c (gfc_alloc_allocatable_for_assignment): Do not use the array bounds of an unallocated array but set its size to zero instead. Modified: branches/gcc-4_8-branch/gcc/fortran/ChangeLog branches/gcc-4_8-branch/gcc/fortran/trans-array.c
Fixed on trunk and 4.8. Thanks for the report Paul