[Bug middle-end/97656] New: Specify that there is no address arithmetic on a pointer

tkoenig at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Oct 31 16:40:45 GMT 2020


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

            Bug ID: 97656
           Summary: Specify that there is no address arithmetic on a
                    pointer
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tkoenig at gcc dot gnu.org
  Target Milestone: ---

This involves Fortran, but possibly also other languages.

Consider

$ cat alias.f90
program main
  interface
     subroutine foo(a)
       integer, intent(inout) :: a
     end subroutine foo
  end interface
  integer, dimension(2) :: x
  x(1) = 42
  x(2) = 42
  call foo(x(1))
  if (x(2) /= 42) stop "Error!"
end program main

This program specifies that foo has a scalar argument, passed by reference.
It is forbidden by Fortran's rules foo could access the element x(2),
therefore the call to stop could be optimized away, but it isn't:

$ gfortran -O3 -S alias.f90 
$ grep _gfortran_stop alias.s 
        call    _gfortran_stop_string
$ 

It would be good if there was a TREE_NO_POINTER_ARITHMETC (or simlar) flag
that could be set by the Fortran front end.


More information about the Gcc-bugs mailing list