This is a follow up to PR 51972 - or rather it's included test case.
The following program fails at run time with a segfault, cf:
Conditional jump or move depends on uninitialised value(s)
at 0x400932: __copy_MAIN___T (nb54af.f90:6)
by 0x400B96: MAIN__ (nb54af.f90:11)
From the dump:
two.a._data.data = (void * restrict) __builtin_malloc (96);
D.1899 = (struct t[0:] * restrict) two.a._data.data;
D.1903 = *two.a._vptr->_def_init
D.1899 + ((S.2 + D.1900) * two.a._vptr->_size));
Thus, there is a MEMSET '\0', CALLOC, or "two.a._data.data = 0" missing as _copy checks the value of the "dst" argument.
Probably, there is an issue with checking for "component->attr.allocatable" while on only has "CLASS_DATA (component)->attr.allocatable". I assume that attr.alloc_comp is correctly set, but the nullification is missed when iterating over the components. Or there is no nullification with _def_init?
integer, allocatable :: x(:)
end type t
class(t), allocatable :: a(:)
end type t2
type(t2) :: two
allocate (two%a(2)) ! ICE: SEGFAULT
The test case mentioned in comment 0 is test4() of the patch submitted at http://gcc.gnu.org/ml/fortran/2012-01/msg00252.html
This is now fixed, since __builtin_memset (two.a._data.data, 0, 96); appears after allocation.
Thanks for this and all the other extracts from Damian and co.'s book!