Skip to content

Strengthen storage variables being unassigned now that we have inline assembly #9651

Open
@chriseth

Description

@chriseth

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking change ⚠️low effortThere is not much implementation work to be done. The task is very easy or tiny.low impactChanges are not very noticeable or potential benefits are limited.must have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions