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

[Bug-Candidate]: redundant control flow edge after try block #2490

Open
Tiko7454 opened this issue Jun 21, 2024 · 2 comments
Open

[Bug-Candidate]: redundant control flow edge after try block #2490

Tiko7454 opened this issue Jun 21, 2024 · 2 comments
Labels
bug-candidate Bugs reports that are not yet confirmed

Comments

@Tiko7454
Copy link
Contributor

Tiko7454 commented Jun 21, 2024

Describe the issue:

when I print the cfg, it gives an edge from node 1 to node 8 (from try head to b += 123)

Code example to reproduce the issue:

pragma solidity ^0.8.0;

contract D{
    function divide(uint256 a, uint256 b) public returns (uint256) {
        require(b != 0, "Division by zero");
        return a / b;
    }
    function safeDivide(uint256 a, uint256 b) public  returns (uint256, string memory) {
        try this.divide(a, b) returns (uint256 result) {
            a++;
        } catch Error(string memory reason) {
           b++;
        } catch (bytes memory) {
            a += 8;
        }
        b+=123;
    }
}

Version:

0.10.3

Relevant log output:

No response

@Tiko7454 Tiko7454 added the bug-candidate Bugs reports that are not yet confirmed label Jun 21, 2024
@0xalpharush
Copy link
Contributor

Do you mind uploading the CFG?

@Tiko7454
Copy link
Contributor Author

digraph{
0[label="Node Type: ENTRY_POINT 0
"];
0->1;
1[label="Node Type: TRY 1

EXPRESSION:
result = this.divide(a,b)

IRs:
TMP_3(uint256) = HIGH_LEVEL_CALL, dest:this(address), function:divide, arguments:['a', 'b']  
result(uint256) := TMP_3(uint256)"];
1->2;
1->4;
1->6;
1->8;
2[label="Node Type: CATCH 2
"];
2->3;
3[label="Node Type: EXPRESSION 3

EXPRESSION:
a ++

IRs:
TMP_4(uint256) := a(uint256)
a(uint256) = a (c)+ 1"];
3->8;
4[label="Node Type: CATCH 4
"];
4->5;
5[label="Node Type: EXPRESSION 5

EXPRESSION:
b ++

IRs:
TMP_5(uint256) := b(uint256)
b(uint256) = b (c)+ 1"];
5->8;
6[label="Node Type: CATCH 6
"];
6->7;
7[label="Node Type: EXPRESSION 7

EXPRESSION:
a += 8

IRs:
a(uint256) = a (c)+ 8"];
7->8;
8[label="Node Type: EXPRESSION 8

EXPRESSION:
b += 123

IRs:
b(uint256) = b (c)+ 123"];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-candidate Bugs reports that are not yet confirmed
Projects
None yet
Development

No branches or pull requests

2 participants