The following program fails to raise an error condition in the deallocate statement. The pointer target was not created by an allocate.
! fails on Windows XP
! gcc version 4.4.0 20080312 (experimental) [trunk revision 133139]
! F95 page 83, line 34 says deallocating a pointer whose target
!wasn't created by an ALLOCATE causes error condition
REAL, pointer :: RLA(:)
REAL, TARGET :: RLA1(6)
RLA1 = 0
RLA => RLA1
DEALLOCATE (RLA, STAT = ISTAT)
IF (ISTAT .LE. 0) print *, 'deallocate did not fail!', istat
Confirmed. gfortran deallocates the static memory as valgrind also complains:
==3839== Invalid free() / delete / delete
==3839== at 0x4C2430F: free (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==3839== by 0x4008F2: MAIN__ (aaa.f90:12)
==3839== by 0x4009BB: main (fmain.c:21)
Ouch. That one will be hard to fix without keeping
state around in the descriptor.
works correctly with e.g. ifort and xlf90, so worth fixing somehow.
(In reply to comment #3)
> works correctly with e.g. ifort and xlf90, so worth fixing somehow.
Thomas' #2 is correct - see the present discussion on the list.
I think that we have to bite the bullet and change the API.
Hold this one to 4.5 since it needs the array descriptor reform.
Still present in trunk.