This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

Re: option to check that arguments to PACK conform?


On Wed, Nov 08, 2006 at 10:02:09PM +0100, Tobias Burnus wrote:
> 
> Vivek Rao wrote:
> > gfortran -Wall -fbounds-check xpack_bounds.f90
> > and does not complain at run-time about the
> > nonconformable array arguments to PACK. If there is no
> > option that catches this, I request that one be added.
> >   
> For reshaped, see
>     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28849
> were I added a link to your email (= your example).
> For matmul(), I had filled PR 29572.
> 
> Actually, I think all operations of the type
>   array  = function(array)
> don't seem to be detected. gfortran blindly
> assumes that if you have
>    function foo(...)
>      real, dimension(a) :: foo
> the dimension is indeed "a". The solution is probably to add at compile
> time (-fbounds-check) a check that the size of the array "foo" is indeed
> at least as big as assumed by the function foo.
> 
> For our routines in the library, one has to think how to do it best.
> (This is for pack, reshape, matmul, transpose, etc.) Either one
> duplicates the functions (one with and one without check) -- or one adds
> an if(boundscheck) and decides at any call what to do. I don't know how
> big the run-time speed penalty of this this if + global variable is,
> however.

FX and I briefly discussed this.  I think we want two functions.
In iresolve.c, we would have code of the form

gfc_resolve_reshape(....) {

    if (boundscheck) {
       Set up _gfortran_reshape_checking.  
    } else {
       Use current unchanged code _gfortran_reshape
    }
}

The idea is that if the frontend needs to give the *_checking
routines additional info, we can do it like I did for rrspacing
and spacing.

-- 
Steve


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