public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-59796-4-czdN1qUyui@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59796-4@http.gcc.gnu.org/bugzilla/>

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.


  reply	other threads:[~2014-01-13 23:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 21:53 [Bug fortran/59796] New: " w6ws at earthlink dot net
2014-01-13 23:02 ` kargl at gcc dot gnu.org [this message]
2014-01-14  1:00 ` [Bug fortran/59796] " w6ws at earthlink dot net
2015-10-20 15:07 ` dominiq at lps dot ens.fr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-59796-4-czdN1qUyui@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).