This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/44504] DEALLOCATE aborts program even with STAT=
- 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: 11 Jun 2010 18:04:16 -0000
- Subject: [Bug fortran/44504] DEALLOCATE aborts program even with STAT=
- References: <bug-44504-19309@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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