Strengthen storage variables being unassigned now that we have inline assembly
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
Reported by @magnus237:
The following code does not report a warning because of the self-assignment:
```
function f() external pure {
string storage s1;
s1 = s1; // self-assignment
string storage s2 = s1;
}
```
Now that we have inline-assembly access to the slots, the following code would be a better (more explicit) way of saying "please ignore the warning":
```
function f() external pure {
string storage s1;
assembly { s1.slot := 0 }
string storage s2 = s1;
}
```
Can we change the control-flow-analyzer accordingly, i.e. do not take assignments from variables into account which are themselves not yet initialized?
Contributor guide
Research direction
Start by locating the control-flow analyzer and reproduce the two Solidity examples from the issue, comparing the warning produced for the self-assignment with the inline-assembly form. Done means assignments from storage variables that are not initialized no longer suppress the unassigned-variable warning, while the explicit slot assignment provides the intended way to suppress it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100