I suppose it's common
nowadays to think of
return values as
objects, but the reality is that a return value is nothing more than a
number in a
register.
It doesn't 'go' anywhere, because it isn't a 'thing' that needs to exist such as matter or energy, it is a mere
symbol or
cipher. It
can be destroyed.
When you don't use the returned value of a function it simply sits around until the spot it's being stored in is reused for some other representation.
If you'd like to consider it in absolute physical terms, however, there is an
electrical charge pattern sitting in a bank of transistors into which the function places this number. The electrical charges come from other portions of the processor, and ultimately from a power source, such as a
battery or a
generator.
Since these registers are often implemented in a
symmetric fashion, a one is simply a positive charge on one transistor, while a zero is a positive charge on its twin. Thus it doesn't matter what representation is stored in that logic cell, if it doesn't change no charge is lost (excepting
leakage current), and when it does change a charge is lost and one is gained.
These charges are dumped straight to ground, or, in other words, head right back to the power source.
Of course, we could go into the whole "Charge is represented by moving
electrons, which actually pass from
negative to
positive, therefore charge actually starts out at ground and makes it way back to the top of the processor where it spews from the power pins into the power source."
But I find it confuses computer scientists.