openzeppelin-labs proxy contract

assembly {
  let ptr := mload(0x40)
  calldatacopy(ptr, 0, calldatasize)
  let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0)
  let size := returndatasize
  returndatacopy(ptr, 0, size)

  switch result
  case 0 { revert(ptr, size) }
  default { return(ptr, size) }

In the official documentation, I got this description.

call(g, a, v, in, insize, out, outsize), call contract at address a with input mem[in…(in+insize)) providing g gas and v wei and output area mem[out…(out+outsize)) returning 0 on error (eg. out of gas) and 1 on success

According to my understanding, the output content will be stored in the memory [out, out + outsize).

I am confused, if the last parameter is set to 0, when the method has a return value, whether it will work well.


The call will use those parameters to copy the returned data from the callee to a caller memory location [out, out + outsize). If outsize is zero it means returned data will not be copied to memory. For this to work the callers have to know the callee returned data size.

Since Byzantium fork the new opcodes RETURNDATASIZE and RETURNDATACOPY allows the caller to copy the returned data after the call.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.