-
Notifications
You must be signed in to change notification settings - Fork 980
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
9 changes: 9 additions & 0 deletions
9
...pshots/detectors__detector_IncorrectOperatorExponentiation_0_7_6_incorrect_exp_sol__0.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Test.bad1() (tests/e2e/detectors/test_data/incorrect-exp/0.7.6/incorrect_exp.sol#9-12) has bitwise-xor operator ^ instead of the exponentiation operator **: | ||
- UINT_MAX = 2 ^ 256 - 1 (tests/e2e/detectors/test_data/incorrect-exp/0.7.6/incorrect_exp.sol#10) | ||
|
||
Test.bad0(uint256) (tests/e2e/detectors/test_data/incorrect-exp/0.7.6/incorrect_exp.sol#5-7) has bitwise-xor operator ^ instead of the exponentiation operator **: | ||
- a ^ 2 (tests/e2e/detectors/test_data/incorrect-exp/0.7.6/incorrect_exp.sol#6) | ||
|
||
Derived.slitherConstructorVariables() (tests/e2e/detectors/test_data/incorrect-exp/0.7.6/incorrect_exp.sol#30) has bitwise-xor operator ^ instead of the exponentiation operator **: | ||
- my_var = 2 ^ 256 - 1 (tests/e2e/detectors/test_data/incorrect-exp/0.7.6/incorrect_exp.sol#3) | ||
|
30 changes: 30 additions & 0 deletions
30
tests/e2e/detectors/test_data/incorrect-exp/0.7.6/incorrect_exp.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
contract Test { | ||
|
||
uint my_var = 2 ^ 256-1; | ||
|
||
function bad0(uint a) internal returns (uint) { | ||
return a^2; | ||
} | ||
|
||
function bad1() internal returns (uint) { | ||
uint UINT_MAX = 2^256-1; | ||
return UINT_MAX; | ||
} | ||
|
||
/* Correct exponentiation operator */ | ||
function good0(uint a) internal returns (uint) { | ||
return a**2; | ||
} | ||
|
||
/* Neither operand is a constant */ | ||
function good1(uint a) internal returns (uint) { | ||
return a^a; | ||
} | ||
|
||
/* The constant operand 0xff in hex typically means bitwise xor */ | ||
function good2(uint a) internal returns (uint) { | ||
return a^0xff; | ||
} | ||
} | ||
|
||
contract Derived is Test {} |
Binary file added
BIN
+2.42 KB
tests/e2e/detectors/test_data/incorrect-exp/0.7.6/incorrect_exp.sol-0.7.6.zip
Binary file not shown.