This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Structure Return Testcase
Mark Mitchell <mark@codesourcery.com> writes:
> >>>>> "Geoff" == Geoff Keating <geoffk@geoffk.org> writes:
>
> >> There's really no chioce here: the committee has spoken.
>
> Geoff> Great! What did they say? (And, come to think of it,
> Geoff> which committee?)
>
> Probably we're talking sideways. I meant the ANSI/ISO C committee;
> they've said that you have to do something memmove-like if you don't
> know there's no overlap. That implies that if you do the
> pass-a-pointer-to-the-result trick, then you need to either a)
> guarantee that you pass a temporary or b) use memmove.
>
> That's all I meant; I don't know what each of the various ABIs says
> about this.
Aah, I see.
Yes, in general ISO C requires that the arguments to memcpy() must not overlap.
However, at least on PowerPC, the ABI specifies that when you write
extern struct xxx func(struct xxx *a);
then this gets turned into
extern void func(struct xxx *hidden, struct xxx *a);
and the `hidden' parameter points to a new temporary. So there's an
implication that `hidden' can't overlap `a'. So in this case,
memcpy() is safe; the bug is that we don't properly create a temporary
for `hidden'.
--
- Geoffrey Keating <geoffk@geoffk.org>