[Patch, Fortran] PR 42647: Missed initialization/dealloc of allocatable scalar DT with allocatable component
Tobias Burnus
burnus@net-b.de
Sun Oct 24 11:51:00 GMT 2010
Janus Weil wrote:
> In the meantime: Any further comments on this patch?
No, I think it looks ok. (Looking at the generated code and glancing at
the patch; I have not yet properly read the patch itself.)
* * *
It does not solve the related issues of PR 43018 and PR 45451.
Regarding the former: For the following program, valgrind shows:
Invalid read of size 8
at 0x40087A: MAIN__ (alloc_comp_scalar_1.f90:8)
for the line "a1 = a2".
program main
type :: container_t
integer, allocatable :: entry
end type container_t
type(container_t) :: a2,a1
call myAlloc()
a2%entry = 1
a1 = a2
contains
subroutine myAlloc()
allocate (a2%entry)
end subroutine myAlloc
end program main
The dump looks quite unspectacular. Does anyone see the problem?
MAIN__ ()
{
static struct container_t a2 = {};
static struct container_t a1 = {};
static void myalloc (void);
try
{
a2.entry = 0B;
a1.entry = 0B;
myalloc ();
*a2.entry = 1;
{
void * restrict D.1508;
struct container_t D.1507;
D.1507 = a1;
a1 = a2;
if ((void *) a2.entry != 0B)
{
D.1508 = (void * restrict) __builtin_malloc (8);
a1.entry = (integer(kind=4) *) D.1508;
__builtin_memcpy (a1.entry, a2.entry, 8);
}
else
{
a1.entry = 0B;
}
if (D.1507.entry != 0B)
{
__builtin_free ((void *) D.1507.entry);
}
D.1507.entry = 0B;
}
}
finally
{
if (a1.entry != 0B)
{
__builtin_free ((void *) a1.entry);
}
a1.entry = 0B;
if (a2.entry != 0B)
{
__builtin_free ((void *) a2.entry);
}
a2.entry = 0B;
}
}
Tobias
More information about the Fortran
mailing list