------- Comment #3 from pault at gcc dot gnu dot org 2008-05-18 15:37 -------
> I have to admit, I did not quickly see in the dump (-fdump-tree-original) why
> it is failing; at a glance, both calling "neg_at" in MAIN__ and the assignment
> in "neg_at" itself look ok; and "t2 = -t1" also works.
The reason is that the lhs is deallocated and nulled before the assignment:
if (t1.b.data != 0B)
{
__builtin_free (t1.b.data);
}
t1.b.data = 0B;
D.722 = neg_at (&t1);
at_from_at (&t1, &D.722);
if (D.722.b.data != 0B)
{
__builtin_free (D.722.b.data);
}
D.722.b.data = 0B;
}
Thus a data null is passed to the neg_at.
If the operator assignment is deleted, so that we rely on the intrinsic
assignment for derived types with allocatable components, the correct result is
obtained:
D.719 = t2;
t2 = neg_at (&t1);
if (D.719.b.data != 0B)
{
__builtin_free (D.719.b.data);
}
D.719.b.data = 0B;
I'll have to see how that can be emulated.
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35824