solidity icon indicating copy to clipboard operation
solidity copied to clipboard

"bytes32 constant x" causes disturbance in the stack.

Open androlo opened this issue 11 years ago • 4 comments

contract BytesConstError {
    bytes32 constant x = "test";

    function (){
        g(x);
    }

    function g(bytes32 arg){}
}
Internal compiler error: I sense a disturbance in the stack.

Tested in latest browser compiler and: 0.1.1-0/Release-Linux/g++/int. Removing constant fixes, or just using a literal.

androlo avatar Aug 25 '15 03:08 androlo

It only fails when it's double quoted (even if it's just empty ""). Integer literals works fine.

contract BytesConstError {
    bytes32 constant x = 0x1234;

    function (){
        var xx = x;
    }

}

^ works

Also, if i do this:

contract BytesConstError {
    bytes32 constant x = "aa";

    function (){
        var xx = x;
    }

}

I get this error:

Internal compiler error: Variable size and position mismatch.

androlo avatar Aug 25 '15 03:08 androlo

Similar problem here:

bytes32 constant public NAME = 'MyText';

Solc:

build/cpp-ethereum-8d6f4q/cpp-ethereum-0.9.41+1171SNAPSHOT20150819104856trusty/libsolidity/../libsolidity/CompilerContext.h(55): Throw in function unsigned int dev::solidity::CompilerContext::getStackHeight() const
Dynamic exception type: boost::exception_detail::clone_impl<dev::solidity::InternalCompilerError>
std::exception::what: std::exception
[dev::tag_comment*] =

sillytuna avatar Aug 26 '15 13:08 sillytuna

I seem to get a similar error:

$ solc binary_test.sol Internal compiler error during compilation:
/build/cpp-ethereum-3hbXSC/cpp-ethereum-1.2.9-SNAPSHOT--20160628-6a05dd7~trusty/solidity/libsolidity/codegen/ContractCompiler.cpp(45): Throw in function void StackHeightChecker::check()
Dynamic exception type: boost::exception_detail::clone_impl<dev::solidity::InternalCompilerError>
std::exception::what: std::exception
[dev::tag_comment*] = I sense a disturbance in the stack.

For this file:

$ cat binary_test.sol 
import "Test.sol";
import "binary.sol";

contract BinaryTest is Test {

  function testWriteUint32() {
    bytes memory data = new bytes(8);
    Binary.writeUint32(data, 4, 15, Binary.ByteOrder.BigEndian);

    assertBytesEqual(data, "\x00\x00\x00\x00\x00\x01\xe2\x40");
  }

  function assertBytesEqual(bytes value, bytes expected) {
    assertBytesEqual(value, expected, "Bytes arrays are not equal");
  }

  function assertBytesEqual(bytes value, bytes expected, string message) {
    value.length.assertEqual(expected.length, message);
    for (uint i = 0 ; i < expected.length ; i++) {
      uint(value[i]).assertEqual(uint(expected[i]), message);
    }
  }

}

stevenroose avatar Aug 07 '16 13:08 stevenroose

I think it was because of type 'Binary.ByteOrder.BigEndian'. Having the same in v3.6.x. But not in 4.x

illya13 avatar Feb 05 '17 09:02 illya13