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?


Hi,

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.

Tobias


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