https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109945

--- Comment #29 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #28)
> What I tried to say in comment 26 is that we're allowed to always make the
> extra copy, which means that global is an invalid pointer, so the program
> has UB.
> 
> I think the only flaw in that reasoning is what Richard Smith said in PR
> 84414 comment 2:
> 
> "In fact, I think the *only* problem here is that the above rule does not
> allow the caller and the callee to observe the objects having the same
> address."
> 
> I would argue that it doesn't say they *can't* have the same address (even
> if logically it seems obvious that if we copy a temporary to w then at some
> point there must have been two distinct objects with two distinct addresses).

For the passing in registers case, the usual case is that there isn't just a
single copy but several, one to the registers, another to other registers or
some memory.
And I don't see why it couldn't yield the same final memory as the source
memory.
Usually it will not, in the caller you ask for the stack slot already before
the call, but in case the compiler would ask for it only after the call (in
alloca-ish way), it could happen to have the same address.

Reply via email to