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]: Incorrect SSA form with break #2509

Open
smonicas opened this issue Jul 16, 2024 · 1 comment
Open

[Bug]: Incorrect SSA form with break #2509

smonicas opened this issue Jul 16, 2024 · 1 comment
Labels
bug Something isn't working ir

Comments

@smonicas
Copy link
Contributor

Describe the issue:

The SSA form returns s_3 and p_3 instead of s_2 and p_2 which are correctly returned if the break is removed.

Code example to reproduce the issue:

contract T {
 function a(uint n) public returns(uint,uint){
   uint s = 0;
   uint p = 0;
   
   for (uint i; i < n; i++) {
     s += i;
     p *= i;
     if (i == 3) { break; }
   }
   return (s, p);
 }
}

Version:

0.10.3

Relevant log output:

Function T.a(uint256)
		Expression: s = 0
		IRs:
			s_1(uint256) := 0(uint256)
		Expression: p = 0
		IRs:
			p_1(uint256) := 0(uint256)
		Expression: i < n
		IRs:
			s_2(uint256) := ϕ(['s_3', 's_1'])
			p_2(uint256) := ϕ(['p_1', 'p_3'])
			i_1(uint256) := ϕ(['i_0', 'i_2'])
			TMP_0(bool) = i_1 < n_1
			CONDITION TMP_0
		Expression: s += i
		IRs:
			s_3(uint256) = s_2 (c)+ i_1
		Expression: p *= i
		IRs:
			p_3(uint256) = p_2 (c)* i_1
		Expression: i == 3
		IRs:
			TMP_1(bool) = i_1 == 3
			CONDITION TMP_1
		Expression: i ++
		IRs:
			TMP_2(uint256) := i_1(uint256)
			i_2(uint256) = i_1 (c)+ 1
		Expression: (s,p)
		IRs:
			RETURN s_3,p_3
@smonicas smonicas added the bug-candidate Bugs reports that are not yet confirmed label Jul 16, 2024
@0xalpharush
Copy link
Contributor

Is the CFG and dominator graph correct?

@0xalpharush 0xalpharush added bug Something isn't working ir and removed bug-candidate Bugs reports that are not yet confirmed labels Aug 23, 2024
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: Incorrect SSA form with break [Bug]: Incorrect SSA form with break Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ir
Projects
None yet
Development

No branches or pull requests

2 participants