3

Using .call to invoke a function on another contract,

address B = 0x4a915089aeC328Dac1F0b197Aba7EB8C1853882d;
bytes4 callSig = bytes4(sha3("foo()"));
B.call(callSig);

gives a warning,

Warning: Return value of low-level calls not used.

enter image description here

using

B public b;

b = B(0x4a915089aeC328Dac1F0b197Aba7EB8C1853882d);

b.foo();

gives no warning.

enter image description here

In what ways does b.foo() know that the call is safe, while B.call(callSig) does not ?

1 Answer 1

2

When you use b.foo, the contract checks the return status, and if the call was unsuccessful it throws an exception. When you use the lower level .call, the call will simply return true if the call was successful and false otherwise. The compiler noticed that you never check the return value, and thus could be making the incorrect assumption that the call completed successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.