Hi! This code
program a real, target :: storage(10) real :: s(5) print*,x(5) s = 0 s = x(5) 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 prints: free(): invalid pointer 0x5012a0! 1.000000 2.000000 3.000000 4.000000 5.000000 0.000000 0.000000 0.000000 0.000000 0.000000 on a x86_64. If you delete s=0 statement, the latter line will contain values from uninitialized memory. gfortran --version GNU Fortran 95 (GCC) 4.2.0 20060112 (experimental) Copyright (C) 2005 Free Software Foundation, Inc. Is this supposed to work? Regards, Juha -- Summary: problems with functions returning array pointers? Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jpr at csc dot fi http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25806