https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81758
--- Comment #14 from Paul Thomas <pault at gcc dot gnu.org> ---
The chunk of offending code:
val_p=>NULL(); cep=>NULL()
cep=>this%element(offset,errc)
if(errc.eq.GFC_SUCCESS.and.associated(cep)) then
val_p=>cep%get_value(errc)
is translated to:
val_p._vptr = (struct __vtype__STAR * {ref-all}) &__vtab__STAR;
val_p._len = 0;
val_p._data = 0B;
cep._vptr = (struct __vtype_gfc_base_Gfc_cont_elem_t * {ref-all})
&__vtab_gfc_base_Gfc_cont_elem_t;
cep._data = 0B;
{
struct __class_gfc_base_Gfc_cont_elem_t_p rhs.69;
rhs.69 = this->_vptr->element ((struct __class_gfc_vector_Vector_iter_t_t
*) this, (integer(kind=8) *) offset, &errc);
cep._vptr = rhs.69._vptr;
cep._data = rhs.69._data;
}
if ((logical(kind=4)) (errc == 0 && cep._data != 0B))
{
{
struct __class_gfc_base_Gfc_cont_elem_t_t this.70;
struct __class__STAR_p rhs.71;
this.70 = VIEW_CONVERT_EXPR<struct
__class_gfc_base_Gfc_cont_elem_t_t>(cep);
rhs.71 = cep._vptr->get_value (&this.70, &errc);
val_p._vptr = rhs.71._vptr;
val_p._len = 0;
val_p._data = rhs.71._data;
}
}
Now if I change class(gfc_cont_elem_t), pointer:: cep
to type(gfc_cont_elem_t), pointer:: cep
The code runs correctly - well, all the tests pass and there is no segfault :-)
From the NULLing of cep, the code becomes:
cep = 0B;
{
struct __class_gfc_base_Gfc_cont_elem_t_p D.4458;
D.4458 = this->_vptr->element ((struct __class_gfc_vector_Vector_iter_t_t
*) this, (integer(kind=8) *) offset, &errc);
cep = D.4458._data;
}
if ((logical(kind=4)) (errc == 0 && cep != 0B))
{
{
struct __class_gfc_base_Gfc_cont_elem_t_t class.69;
struct __class__STAR_p rhs.70;
class.69._vptr = (struct __vtype_gfc_base_Gfc_cont_elem_t * {ref-all})
&__vtab_gfc_base_Gfc_cont_elem_t;
class.69._data = cep;
rhs.70 = contelemgetvalue (&class.69, &errc);
val_p._vptr = rhs.70._vptr;
val_p._len = 0;
val_p._data = rhs.70._data;
}
This corresponds to trans_class_vptr_len_assignment NOT being called. I am
rather sure that there is some failure of logic in it.
Paul