GFortran Bug Report: Size of pointer variables

Tobias Burnus burnus@net-b.de
Tue Dec 15 22:16:00 GMT 2009


Am 15.12.2009 22:23, schrieb Steve Kargl:
> See Tobias' email for an answer to the above question.
> To add to your confusion, with gfortran mainline I see
>
>            1
>            1
>        -6928
>   

Well, that's the result of uninitialized memory. As -fdump-tree-original
shows, the bounds will not be initialized only <arraydescriptor>.data,
i.e. all tests except for ALLOCATED() will access invalid memory.

Try the following program. All my compilers print "5" for it: ifort,
gfortran, NAG f95, openf95, g95:

PROGRAM TEST
INTEGER, POINTER :: I(:)
integer, target :: j(5)
I=>j
I=>null()
PRINT *, SIZE(I)
END PROGRAM TEST

Which demonstrates again that size(i) == 0 was probably an artifact of
having no initialization of the bounds.

 * * *

> gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)

I agree with Steve here that you should consider updating. GCC 4.1.2 was
one of the first usable version of gfortran, but several bugs have been
fixed in the meanwhile. The current stable version of GCC is 4.4.2 and
only 4.5, 4.4.2 and 4.3.4 are supported.

Tobias



More information about the Fortran mailing list