From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23991 invoked by alias); 16 Jan 2006 16:54:45 -0000 Received: (qmail 23961 invoked by uid 48); 16 Jan 2006 16:54:42 -0000 Date: Mon, 16 Jan 2006 16:54:00 -0000 Message-ID: <20060116165442.23958.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/25806] problems with functions returning array pointers? In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-01/txt/msg01562.txt.bz2 List-Id: ------- 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