Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use larger operand type as binop result type #53

Merged
merged 2 commits into from
Jul 26, 2023
Merged

Conversation

kevinclancy
Copy link

Notes

This fixes issue 644, which is that the type of the left hand operand is used in a binary operation, even though the larger operand type should be used in the case of integer types.

A better approach would be to insert an explicit cast from the smaller type to the larger type, as noted here. However, the current PR's approach is easier and works, as far as I know.

Testing

  • Get a local copy of the companion PR and follow its testing instructions.

Related Issue

https://github.com/CertiKProject/slither-task/issues/644

@kevinclancy kevinclancy requested a review from duckki July 24, 2023 21:07
@duckki
Copy link

duckki commented Jul 25, 2023

Otherwise, I confirmed this PR (along with the companion PR) fixed the crash.
This source file is no longer crashing:
https://github.com/ChainGPT-org/pad-staking-contracts/tree/f669f2c3021b2b8718ab8dc1dbb6584a1d77a90e/contracts/contracts/AllocationPool.sol.

@kevinclancy kevinclancy requested a review from duckki July 25, 2023 23:57
@duckki duckki merged commit 6c8d324 into certik Jul 26, 2023
kevinclancy added a commit that referenced this pull request Jul 28, 2023
* when binop operand types have different sizes, use the larger one for the result
* when types of left and right operand have the same size, use the left one

https://github.com/CertiKProject/slither-task/issues/644
@chenhuitao chenhuitao deleted the binop-type-fix branch March 18, 2024 10:42
whonore pushed a commit that referenced this pull request May 24, 2024
* when binop operand types have different sizes, use the larger one for the result
* when types of left and right operand have the same size, use the left one

https://github.com/CertiKProject/slither-task/issues/644
whonore pushed a commit that referenced this pull request May 24, 2024
* when binop operand types have different sizes, use the larger one for the result
* when types of left and right operand have the same size, use the left one

https://github.com/CertiKProject/slither-task/issues/644
whonore pushed a commit that referenced this pull request May 28, 2024
* when binop operand types have different sizes, use the larger one for the result
* when types of left and right operand have the same size, use the left one

https://github.com/CertiKProject/slither-task/issues/644
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants