For example, when a struct is initialised to storage in a function, then assigned to a global state variable such as an array or mapping type, does the local struct get copied to the global state variable, or does the global state variable reference the local struct?
The solidity docs say that local storage variables can reference global state, but it doesn't specify if it works both ways?? E.g.
contract C {
struct S {
uint n;
}
// Global state mapping:
mapping (uint => S) m;
// Is data copied or referenced from the local storage object in the function to global storage??
function localToGobal(uint i) public {
S storage obj = S(i);
m[i] = obj;
}