This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/39189] New: Improvement in handling COMMON'ed pointers to allocatable arrays


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]