public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/39189]  New: Improvement in handling COMMON'ed pointers to allocatable arrays
@ 2009-02-14  2:04 boldin dot pavel at gmail dot com
  2009-02-14 16:00 ` [Bug fortran/39189] " kargl at gcc dot gnu dot org
  2009-02-19  5:40 ` pault at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: boldin dot pavel at gmail dot com @ 2009-02-14  2:04 UTC (permalink / raw)
  To: gcc-bugs

When using perverted technique like:

SUBROUTINE A
INTEGER, ALLOCATABLE, DIMENSION(:), TARGET :: ARRAY
INTEGER, POINTER, DIMENSION(:) :: ARRAY_PTR
COMMON /AP/ ARRAY_PTR !for later use in another sub

ALLOCATE(ARRAY(10))
ARRAY = 10
ARRAY_PTR => ARRAY

END SUBROUTINE A

SUBROUTINE B
INTEGER, POINTER, DIMENSION(:) :: ARRAY_PTR
COMMON /AP/ ARRAY_PTR !for later use in another sub

print *, ARRAY_PTR(1)
END SUBROUTINE


one can figure out, that ARRAY will be free'd after finishing subroutine A
(because it was not SAVE'd). But gfortran still allows to play such a trick.

I think it would be nice to see warning in such case (pointing to data that
will be lost after this scope)


-- 
           Summary: Improvement in handling COMMON'ed pointers to
                    allocatable arrays
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: boldin dot pavel at gmail dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug fortran/39189] Improvement in handling COMMON'ed pointers to allocatable arrays
  2009-02-14  2:04 [Bug fortran/39189] New: Improvement in handling COMMON'ed pointers to allocatable arrays boldin dot pavel at gmail dot com
@ 2009-02-14 16:00 ` kargl at gcc dot gnu dot org
  2009-02-19  5:40 ` pault at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-02-14 16:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from kargl at gcc dot gnu dot org  2009-02-14 16:00 -------
I'm inclined to think that this should be closed with WONTFIX.

Deallocation of an allocated array when a subprogram returns
is a fundamental concept of Fortran.  A user should know what
to expect and code accordingly.

I'll let one of the other gfortran contributors make a final
determination of the merits of a warning.


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P5


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug fortran/39189] Improvement in handling COMMON'ed pointers to allocatable arrays
  2009-02-14  2:04 [Bug fortran/39189] New: Improvement in handling COMMON'ed pointers to allocatable arrays boldin dot pavel at gmail dot com
  2009-02-14 16:00 ` [Bug fortran/39189] " kargl at gcc dot gnu dot org
@ 2009-02-19  5:40 ` pault at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-02-19  5:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pault at gcc dot gnu dot org  2009-02-19 05:40 -------
I agree with Steve and have marked this as WONTFIX.

You should use another pointer and allocate to that if you want to avoid the
automatic deallocation on leaving scope.

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-02-19  5:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-14  2:04 [Bug fortran/39189] New: Improvement in handling COMMON'ed pointers to allocatable arrays boldin dot pavel at gmail dot com
2009-02-14 16:00 ` [Bug fortran/39189] " kargl at gcc dot gnu dot org
2009-02-19  5:40 ` pault at gcc dot gnu dot org

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).