[Bug fortran/59398] New: Wrong bounds for allocatable result and for
loximann at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Dec 5 18:14:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59398
Bug ID: 59398
Summary: Wrong bounds for allocatable result and for
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: loximann at gmail dot com
The lower bounds of the result of an allocatable array-valued function are
always set to 1.
Also, I discovered that if LHS is allocated and has the same size as RHS, the
bounds are not changed.
This code illustrates it:
************************************************
program return_allocatable
implicit none
real, allocatable :: a(:)
real, parameter :: b(-2:4)=[1,2,3,4,5,6,7]
a=foo(3)
print*,lbound(a),':',ubound(a)
a=b
print*,lbound(a),':',ubound(a)
contains
function foo(n)
integer :: n
real, allocatable :: foo(:)
allocate(foo(-3:n))
foo=n
end function
end program
************************************************
The expected output is
-3:3
-2:4
but instead I get
1:7
1:7
More information about the Gcc-bugs
mailing list