http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59796
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #2 from kargl at gcc dot gnu.org --- (In reply to Walter Spector from comment #0) > Yes, this is probably a duplicate of the now-closed bug 44504. > > The following code returns a stat of 0 from g95, PGI (v13.8), and NAG > (v5.3.1). However Intel and gfortran abend - which is not very friendly. > Who is right? > > program double_dealloc > implicit none > > integer, pointer :: ip1(:), ip2(:) > integer :: memstat > > allocate (ip1(42)) > ip2 => ip1 > deallocate (ip1) > deallocate (ip2, stat=memstat) > print *, 'memstat =', memstat > > end program > > The Fortran 2008 Standard, in section 6.7.4 pertaining to the STAT= > specifier, starts off somewhat vague with respect to STAT= when there is an > error. In paragraph 2 it only states that upon success, a value of 0 is set. I believe the code is invalid, so gfortran can do whatever it wants. 6.7.3.3 in F08 states: If a pointer appears in a DEALLOCATE statement, its association status shall be defined. When you deallocate ip1, doesn't the associate status of ip2 become undefined? If fact, 16.5.2.8 appears to muddy the waters. It states If the association status of a pointer is disassociated or undefined, the pointer shall not be referenced or deallocated. Whatever its association status, a pointer always may be nullified, allocated, or pointer assigned. A nullified pointer is disassociated. When a pointer is allocated, it becomes associated but undefined. One might argue about quality of implementation of gfortran, but in the end it seems to be the programmers responsibility to ensure the pointer is not undefined.