When I tried this code at Compiler Explorer, it shows that the compiler inserts a call to memcpy here. Why doesn't it reuse the memory, since the incoming struct is going to be dropped anyway?
If you look at test, you will see a memset, and no copies. The memcpy in foobar is because it need to do some copying around to maintain it's ABI, moving stuff from the inputs to the output slot, but this can be trivially optimized away as seen in test.