strange valgrind error?!

Daniel Franke franke@embl-hamburg.de
Sat Oct 23 07:31:00 GMT 2010


Hi all.

While experimenting, I came across a rather strange valgrind error.
With this code (which I believe to be valid, but read on):

  REAL, POINTER :: x(:)
  x => NULL()
  CALL foo(x, 0)
CONTAINS
  SUBROUTINE foo(x, n)
    INTEGER n
    REAL x(n)
  END SUBROUTINE
END

valgrind complains for binaries compiled with 4.4, 4.5 and current trunk:

==27261== Conditional jump or move depends on uninitialised value(s)
==27261==    at 0x40DCCD0: _gfortran_internal_pack (in_pack_generic.c:53)
==27261==    by 0x8048558: MAIN__ (inpack.f90:3)
==27261==    by 0x80485C8: main (inpack.f90:4)

Although there is not a single element to pack to begin with.

If
	x => NULL()

is replaced with
	ALLOCATE(x(0))

valgrind stops complaining.

in the first case, the dump only has:
  x.data = 0B;

while in the second:
    x.dtype = 281;
    :
    x.data = ...


in_pack_generic.c one finds:
51  type_size = GFC_DTYPE_TYPE_SIZE(source);
52  size = GFC_DESCRIPTOR_SIZE (source);
53  switch (type_size)

with
#define GFC_DTYPE_TYPE_SIZE(desc) ((desc)->dtype & GFC_DTYPE_TYPE_SIZE_MASK)


Finally my question: is my initial code wrong after all, or should the dtype 
be properly initialized from the start?

Thanks

	Daniel



More information about the Fortran mailing list