pragma solidity ^0.4.17;
pragma experimental ABIEncoderV2;
contract Person {
mapping(uint256 => Document) documents;
struct Document {
uint256 value;
uint256 value2;
}
function getDocument(uint256 _document) public returns (Document) {
return documents[_document];
}
}
contract Service
{
function getPersonalDocument(Person _person, uint256 _document) public {
Person.Document memory document = _person.getDocument(_document);
}
}
error received "InternalCompilerError: Static memory load of more than 32 bytes requested.".
FWIW changing struct to single value compiles correctly.
I tried to simplify the example.
Without argument everything is fine - function noError.
pragma solidity ^0.4.17;
contract Person {
struct Document {
uint256 value;
uint8 value2;
}
function withError(Person _person) public returns (Document) {
return _person.withError(_person);
}
function noError() public returns (Document) {
return noError();
}
}
Hi thanks, oddly that doesn't compile for me using Remix with compiler 0.4.17+commit.bdeb9e52.Emscripten.clang
Ah sorry are you confirming the problem?
@MrHash
yes, I confirm the bug. Exception is here https://github.com/ethereum/solidity/blob/81f9f86ce51d2e9b54bf76b1169f12e193c79745/libsolidity/codegen/CompilerUtils.cpp#L1013
everything is fine if there is no function argument or return type is less then 32 bytes (for example, uint256)
Ah, it turns out that the new ABI decoder is just not yet implemented for retrieving function return values. Once this is implemented, it will also make use of the new opcodes returndatasize and returndatacopy.
I can reproduce the problem on 0.4.18
@lgrapenthin yes, we did not yet have time to work on this.
As this problem still exists are there suggested workarounds? Is the code fine and we just need to wait for an update, or should we be keeping all structs at less than 32 bytes of storage.
Have same problem, compiling:
pragma solidity ^0.4.18;
contract Experiment {
struct MyStruct {
int a;
int b;
}
MyStruct data;
function setData(MyStruct _data) public {
data = _data;
}
}
creates compilation error:
truffle(develop)> compile
Compiling ./contracts/Experiment.sol...
InternalCompilerError: Static memory load of more than 32 bytes requested.
Compilation failed. See above.
truffle(develop)>
Using:
struct MyStruct {
int a;
// int b;
}
Passes compilation successfully
Any new update?
Faced with the same issue
For what its worth, this is limited to public functions. If you can make it internal or private the problem is circumvented.
Most helpful comment
Any new update?