This is the mail archive of the gcc-patches@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]

[Patch, Fortran] PR 81770: [5/6/7 Regression] Bogus warning: Pointer in pointer assignment might outlive the pointer target


Hi all,

the attached patch fixes a bogus warning. The purpose of the warning
is to detect cases where a pointer lives longer than its target. If
the target itself is (1) a pointer or (2) a component of a DT pointer,
we do not know about the lifetime of the target at compile time and no
warning should be thrown. The existing check only handles case (1) and
my patch adds the handling of case (2).

Regtestes cleanly on x86_64-linux-gnu. Ok for trunk and the release branches?

Cheers,
Janus



2017-08-27  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/81770
    * expr.c (gfc_check_pointer_assign): Improve the check whether pointer
    may outlive pointer target.


2017-08-27  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/81770
    * gfortran.dg/warn_target_lifetime_4.f90: New testcase.

Attachment: pr81770.diff
Description: Text document

! { dg-do compile }
! { dg-options "-Wtarget-lifetime" }
!
! PR fortran/81770: [5/6/7 Regression] Bogus warning: Pointer in pointer assignment might outlive the pointer target
!
! Contributed by Janus Weil <janus@gcc.gnu.org>

module m

   type t
      integer, allocatable :: l
   end type

contains

   subroutine sub(c_in, list)
      type(t), target, intent(in)  :: c_in
      integer, pointer, intent(out) :: list

      type(t), pointer :: container

      container => c_in

      list => container%l

   end subroutine

end

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