This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/35810] [TR 15581 / F2003] Automatic reallocation on assignment to allocatable variables
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Oct 2008 17:37:59 -0000
- Subject: [Bug fortran/35810] [TR 15581 / F2003] Automatic reallocation on assignment to allocatable variables
- References: <bug-35810-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from burnus at gcc dot gnu dot org 2008-10-28 17:37 -------
Segfault with return values of allocatable functions.
A code which does not work is the following TR15581-conform program.
It seqfaults (SIGABRT) and valgrind shows errors of the kind:
==12853== Invalid write of size 4
==12853== at 0x400966: MAIN__ (aa.f90:7)
==12853== Address 0x58e7b4c is 0 bytes after a block of size 4 alloc'd
==12853== at 0x4C256AE: malloc (in
/usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==12853== by 0x4008A4: MAIN__ (aa.f90:4)
Test case:
implicit none
integer,allocatable :: j(:)
integer :: i
allocate(j(1))
do i = 1,200000
! deallocate(j)
j = alloc()
end do
contains
function alloc()
integer, allocatable :: alloc(:)
allocate(alloc(10000))
end function
end
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|enhancement |normal
Keywords| |wrong-code
Summary|[F2003] Automatic |[TR 15581 / F2003] Automatic
|reallocation on assignment |reallocation on assignment
|to allocatable variables |to allocatable variables
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35810