This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/60500] New: Spurious warning on derived type initialization
- From: "jonathan.hogg at stfc dot ac.uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 11 Mar 2014 10:56:19 +0000
- Subject: [Bug fortran/60500] New: Spurious warning on derived type initialization
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60500
Bug ID: 60500
Summary: Spurious warning on derived type initialization
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jonathan.hogg at stfc dot ac.uk
The following code:
module spurious_warning
implicit none
type :: ntype
integer :: level = 1
end type ntype
contains
subroutine sub1(n1, n2, st)
integer, intent(in) :: n1, n2
integer, intent(out) :: st
type(ntype), dimension(:), allocatable :: work1
integer, dimension(:), allocatable :: work2
allocate(work1(n1), stat=st)
if(st.ne.0) return
allocate(work2(n2), stat=st)
if(st.ne.0) return
end subroutine sub1
end module spurious_warning
Produces the following spurious warning:
[user@host]$ gfortran-4.8 -O2 -Wall -c bug.f90
bug.f90: In function âsub1â:
bug.f90:12:0: warning: âwork1.dim[0].uboundâ may be used uninitialized in this
function [-Wmaybe-uninitialized]
type(ntype), dimension(:), allocatable :: work1
^
With the following compiler version:
GNU Fortran (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1
Notes:
Removal of -O2 removes the sprurious warning.
Removal of the second allocation removes spurious warning.
Removal of default value in type definition removes spurious warning.
Working theory: The automatic initialization accesses array size as part of
implementation?