[gfortran] Fix NULL reference types.

Paul Brook paul@codesourcery.com
Thu Aug 19 21:04:00 GMT 2004


On Thursday 19 August 2004 21:16, Toon Moene wrote:
> Paul Brook wrote:
> > On Thursday 19 August 2004 18:55, Daniel Jacobowitz wrote:
> >>I suspect we know that Fortran's reference types can't trap if they are
> >>non-NULL, also.  That might be nice to represent also.
> >
> > In Fortran they can trap on write, but not on read.
>
> Are you sure ? In a legal Fortran program you have to pass a legal
> (variable, array element, array) as an actual argument to a subprogram.

The argument only has to be definable if you actually execute a statement that 
defines the argument. 

> When its INTENT shows that it is OK to write to it, it better be an OK
> address to write to.
>
> Or am I missing something in your reasoning ?

procedure foo(a, b)
  integer a, b, i

  ! Assuming do i=1,0 executes zero times.
  do i=1, b 
    a = i
  end do
end procedure

If we assume a does not trap, this can be optimized to:

procedure foo(a, b)
  integer a, b

  a = b
end procedure

Which will then segfault when invoked as 
call foo(0, 0)

Paul



More information about the Gcc-patches mailing list