GFortran Bug Report: Size of pointer variables

Tink,James [NCR] James.Tink@ec.gc.ca
Tue Dec 15 20:52:00 GMT 2009


I apologize for sending a bug report via e-mail but I don't understand
the bugzilla system, I'll try to submit bugs through it in the future.

I tried to compile the following source (in test.f90):

PROGRAM TEST
INTEGER, POINTER :: I(:)
I=>NULL()
PRINT *, SIZE(I)
END PROGRAM TEST
 
Using:

gfortran test.f90 -o test.e

When running test.e, I get the following output:

           1

I tried to compile the same code using the Portland Group's Fortran 90
compiler:

pgf90 test.f90 -o test.e

And get the following output from running test.e:

            0

Which compiler is producing the correct output and why?

I would expect that the size of a pointer variable which is not
associated (and pointing to NULL) would have size 0. This caused many of
my programs compiled with GFortran to produce segmentation faults, where
I assumed that an array with a non-zero size (which could possibly be a
non-associated array in GFortran) has associated values. I realize that
there is the ASSOCIATED intrinsic specifically to avoid this problem,
but GFortran's behaviour is unexpected regardless and no other compilers
that I know of have this same issue.

The output of gfortran -v on my system is:
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)

I'd be happy to give additional information upon request. Thanks for
your help,

James Tink
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.f90
Type: application/octet-stream
Size: 82 bytes
Desc: test.f90
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20091215/954ec409/attachment.obj>


More information about the Fortran mailing list