pragma solidity >=0.0;
pragma experimental ABIEncoderV2;
contract C {
bytes x_0 = "0";
function f() public returns (bool) {
return (this.g_public(x_0) && this.g_external(x_0));
}
function stringCompare(string memory a, string memory b) internal pure returns (bool) {
if(bytes(a).length != bytes(b).length)
return false;
else
return keccak256(bytes(a)) == keccak256(bytes(b));
}
function bytesCompare(bytes memory a, bytes memory b) internal pure returns (bool) {
if(a.length != b.length)
return false;
for (uint i = 0; i < a.length; i++)
if (a[i] != b[i])
return false;
return true;
}
function g_public(bytes memory g_0) public view returns (bool) {
if (!bytesCompare(g_0, "0")) return false;
return true;
}
function g_external(bytes calldata g_0) external view returns (bool) {
if (!bytesCompare(g_0, "0")) return false;
return true;
}
}
returns false (0x000...00) when it should return true (0x00...01)
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository -y ppa:ethereum/ethereum
$ sudo apt-get update
$ sudo apt-get install ethereum
$ solc --bin-runtime contract.sol 2>/dev/null | grep -A1 "Binary of the runtime" | grep -v Binary > bytecode
$ evm --prestate genesis.json --codefile bytecode --input 26121ff0 run
0x0000000000000000000000000000000000000000000000000000000000000000
where genesis.json is
{
"nonce": "0x0000000000000000",
"difficulty": "0x01",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"number": "0x7D0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x3D0900",
"alloc": {},
"config": {
"eip150Block": 0,
"eip158Block": 0,
"eip155Block": 0,
"homesteadBlock": 0,
"daoForkBlock": 0,
"byzantiumBlock": 2000,
"constantinopleBlock": 2000,
"petersburgBlock": 2000
}
}
Did you actually run the constructor code or just the runtime code? Without the constructor code, the initialization of x_0 = "0" does not happen.
I see, I ran just the runtime code. Closing this issue as a false positive.
Maybe it is best to just add a second contract of the form
contract Factory {
function() public { C c = new C(); c.f(); }
}
Then you do not even need to care about function signatures and can just execute the runtime code of the Factory function without any additional data.