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/86312] New: missing runtime warning for array temporary with -fcheck=array-temps


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86312

            Bug ID: 86312
           Summary: missing runtime warning for array temporary with
                    -fcheck=array-temps
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janus at gcc dot gnu.org
  Target Milestone: ---

Consider this test case:


program array_temp

 type :: t
   integer :: i = 3
   real    :: r = 0.
 end type

 integer, allocatable, dimension(:,:) :: ia
 type(t), dimension(10) :: xx

allocate(ia(1:10,1:10), source=1)
call sub(ia(1,:))   ! runtime warning: array temporary
call sub(ia(:,1))

call sub(xx(:)%i)   ! no runtime warning?!?

contains

   subroutine sub(arg)
      integer, dimension(:), contiguous :: arg
      print *, arg
   end subroutine

end



The flag -Warray-temporaries correctly warns for array temporaries at compile
time:

array_temp.f90:12:9:

 call sub(ia(1,:))   ! runtime warning: array temporary
         1
Warning: Creating array temporary at (1) for argument ‘arg’
[-Warray-temporaries]
array_temp.f90:15:9:

 call sub(xx(:)%i)   ! no runtime warning?!?
         1
Warning: Creating array temporary at (1) [-Warray-temporaries]


However, -fcheck=array-temps only catches the first case, not the second one.


Related question: If the compile-time check catches all of this, why do we need
a runtime check at all? Are there cases that are only catchable at runtime, but
not at compile time?


Minor documentation issue: -Warray-temporaries is not listed on
https://gcc.gnu.org/onlinedocs/gfortran/Option-Summary.html, therefore I had a
hard time finding it. Also: Couldn't it be included in -Wall or at least
-Wextra?

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