From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1656 invoked by alias); 13 Jan 2014 23:02:17 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 1612 invoked by uid 48); 13 Jan 2014 23:02:13 -0000 From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/59796] Deallocate aborts even with STAT= Date: Mon, 13 Jan 2014 23:02:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-01/txt/msg01409.txt.bz2 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.