This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: option to check that arguments to PACK conform?
- From: Tobias Burnus <burnus at net-b dot de>
- To: Vivek Rao <vivekrao4 at yahoo dot com>
- Cc: fortran at gcc dot gnu dot org
- Date: Wed, 08 Nov 2006 22:02:09 +0100
- Subject: Re: option to check that arguments to PACK conform?
- References: <20061108191008.55101.qmail@web53404.mail.yahoo.com>
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