[Bug fortran/44504] DEALLOCATE aborts program even with STAT=

burnus at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jun 11 18:04:00 GMT 2010



------- Comment #1 from burnus at gcc dot gnu dot org  2010-06-11 18:04 -------
I think this is a bug in your program:

allocate (a) ! Allocate memory
p1 => a
p2 => a

! All of {a, p1, p2} point to the same memory.

deallocate (p1, stat=ios)

! Free memory pointed to by {a, p1, p2}
! and mark "p1" as disassociated / not-allocated
!
! p2 and a have the pointer-association status "undefined"

deallocate (p2, stat=ios)

! Invalid: Access to pointer with "undefined" pointer association status.



Or to put into standard speech: http://gcc.gnu.org/wiki/GFortranStandards

"A pointer may have a pointer association status of associated, disassociated,
or undefined. Its association status may change during execution of a program.
Unless a pointer is initialized (explicitly or by default), it has an initial
association status of undefined. A pointer may be initialized to have an
association status of disassociated or associated."


"16.5.2.5 Events that cause the association status of pointers to become
undefined":

"(3) the target of the pointer is deallocated other than through the pointer,"


And finally:
"A pointer that is not associated shall not be referenced or defined."
and
"If a pointer appears in a DEALLOCATE statement, its association status shall
be defined."


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44504



More information about the Gcc-bugs mailing list