SRI-CSL / solidity

This is solc-verify, a modular verifier for Solidity.
https://github.com/SRI-CSL/solidity/blob/boogie/SOLC-VERIFY-README.md
GNU General Public License v3.0
50 stars 14 forks source link

Local storage pointers and inheritance #47

Open hajduakos opened 5 years ago

hajduakos commented 5 years ago

Depending on the target of verification, the postcondition of setB0 might or might not hold.

pragma solidity >=0.5.0;

contract A {
  struct S {
      int x;
  }
  function setA0(S storage s_ptr) internal {
    s_ptr.x = 0;
  }
}

contract B is A {
  S s;
  /// @notice postcondition s.x == 0
  function setB0(S storage s_ptr) internal {
    setA0(s_ptr);
  }
}

contract LocalStorageSpec is B {
  S s;
  function setC0(S storage s_ptr) internal {
    setB0(s_ptr);
  }
  function() external payable {
    setC0(s);
    assert(s.x == 0);
  }

}

If we only target B without C, it should hold. Otherwise it should not.