'Transferring msv.value within the body of a function in solidity

If I have a payable function in Solidity, can I transfer msg.value directly to another address without having funds in the contract. For example:

function foo() payable {
  myaddr.transfer(msg.value);
}

If the contract has not received any funds yet, will this work? Or will it only work if there are at least msg.value worth of funds from a previous transaction? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source