ALLOCATE and STAT, take 2
Salvatore Filippone
salvatore.filippone@uniroma2.it
Tue Jun 5 09:08:00 GMT 2007
Hi,
Further to our previous discussion about the possible ways for ALLOCATE
to fail, I went ahead and built an example where the allocation size
overflows into positive integers (on a 32 bit machine), and here's the
outcome.
Ideas on what can be done? Note that here we have
(SIZE(X,1)>0).and.(SIZE(X,2)>0).and.(SIZE(X)<SIZE(X,1))
which ought to be impossible.
Thanks
Salvatore
---------------------------- log-------------------
[sfilippo@localhost bugtest]$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.2.0/configure --prefix=/usr/local/gcc42
--with-mpfr=/home/travel/GCC/BUILDS/mpfr
--with-gmp-lib=/home/travel/GCC/BUILDS/gmp/lib/
--with-gmp=/home/travel/GCC/BUILDS/gmp
Thread model: posix
gcc version 4.2.0
[sfilippo@localhost bugtest]$ gfortran -o tryalloc2 tryalloc2.f90
[sfilippo@localhost bugtest]$ ./tryalloc2
2147483647 805306367
On output : 0 1342177281 2147483647 805306367
On output : T
-------------------- tryalloc2.f90 ------------------------
program tryalloc
integer, allocatable :: x(:,:)
integer :: info,i,j,k, n
i=2147483647
j=805306367
write(*,*) i,j
allocate(x(i,j),stat=info)
write(*,*) 'On output : ',info,size(x),size(x,1),size(x,2)
write(*,*) 'On output : ',(size(x)<size(x,1))
end program tryalloc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 1614 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070605/070870e4/attachment.bin>
More information about the Fortran
mailing list