What does this function return? EthernetClass::localIP()

Here is the function:

IPAddress EthernetClass::localIP()
  IPAddress ret;
  return ret;

It looks to me like it's returning a local object which will no longer be valid after it returns, or am I missing something?

I'd understand why you'd think that. But whats actually happening is it's creating that local object, changing it, then when it goes to return it, it makes a copy and returns that.

Although thats the process, the compiler should optimise this so the copy never takes place.

Good point and now it makes sense. Thank you for explaining this :)