This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/25806] problems with functions returning array pointers?
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Jan 2006 16:54:42 -0000
- Subject: [Bug fortran/25806] problems with functions returning array pointers?
- References: <bug-25806-11807@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from rguenth at gcc dot gnu dot org 2006-01-16 16:54 -------
Shorter testcase:
program a
real, target :: storage(2)
real :: s(2)
s = x(2)
print*,s
contains
function x(n) result(t)
integer :: n
real, pointer :: t(:)
t => storage(1:n)
! allocate( t(n) )
t = (/ (i,i=1,n) /)
end function x
end program a
looks like the FE generates wrong trees: .03.gimple is
MAIN__ ()
{
real4[0:] * D.831;
real4 storage[2];
real4 s[2];
static void x (struct array1_real4 &, int4 &);
_gfortran_set_std (118, 127);
{
int4 * D.828;
int4 C.827 = 2;
struct array1_real4 parm.3;
parm.3.dtype = 281;
parm.3.dim[0].lbound = 1;
parm.3.dim[0].ubound = 2;
parm.3.dim[0].stride = 1;
D.831 = (real4[0:] *) &s[0];
parm.3.data = D.831;
parm.3.offset = 0;
D.828 = &C.827;
x (&parm.3, D.828);
}
{
struct __st_parameter_dt dt_parm.4;
dt_parm.4.common.filename = "t3.f90";
dt_parm.4.common.line = 6;
dt_parm.4.common.unit = 6;
dt_parm.4.common.flags = 128;
_gfortran_st_write (&dt_parm.4);
{
struct array1_real4 parm.5;
parm.5.dtype = 281;
parm.5.dim[0].lbound = 1;
parm.5.dim[0].ubound = 2;
parm.5.dim[0].stride = 1;
D.831 = (real4[0:] *) &s[0];
parm.5.data = D.831;
parm.5.offset = 0;
_gfortran_transfer_array (&dt_parm.4, &parm.5, 4, 0);
}
_gfortran_st_write_done (&dt_parm.4);
}
}
Note the call to _gfortran_st_write is before the array transfer.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25806