public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/25806]  New: problems with functions returning array pointers?
@ 2006-01-16 10:35 jpr at csc dot fi
  2006-01-16 16:30 ` [Bug fortran/25806] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jpr at csc dot fi @ 2006-01-16 10:35 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-02-14 20:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-16 10:35 [Bug fortran/25806] New: problems with functions returning array pointers? jpr at csc dot fi
2006-01-16 16:30 ` [Bug fortran/25806] " pinskia at gcc dot gnu dot org
2006-01-16 16:54 ` rguenth at gcc dot gnu dot org
2006-02-04 17:11 ` eedelman at gcc dot gnu dot org
2006-02-04 20:52 ` eedelman at gcc dot gnu dot org
2006-02-06 21:51 ` eedelman at gcc dot gnu dot org
2006-02-12 17:34 ` eedelman at gcc dot gnu dot org
2006-02-14 17:34 ` eedelman at gcc dot gnu dot org
2006-02-14 20:31 ` eedelman at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).