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

Optimizer bug (v0.8.13-0.8.28) #15707

Open
m4k2 opened this issue Jan 10, 2025 · 0 comments
Open

Optimizer bug (v0.8.13-0.8.28) #15707

m4k2 opened this issue Jan 10, 2025 · 0 comments
Labels

Comments

@m4k2
Copy link

m4k2 commented Jan 10, 2025

Description

The optimizer incorrectly removes sstore instructions in initialization code when followed by a call to an undefined internal function (foo()).

Environment

  • Compiler version: 0.8.28
  • Target EVM version (as per compiler settings): Cancun
  • Framework/IDE (e.g. Truffle or Remix): None
  • EVM execution environment / backend / blockchain client: None
  • Operating system: Linux

Steps to Reproduce

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

contract A {
    function() internal foo;

    constructor(uint256 x, bytes memory) {
        assembly {
            sstore(1, x)
        }

        foo();
    }
}
$ solc-select install 0.8.12 && solc-select use 0.8.12
Installing solc '0.8.12'...
Version '0.8.12' installed.
Switched global version to 0.8.12

$ solc --optimize --ir-optimized src/A.sol | grep sstore
            sstore(1, var_x)

$ solc-select install 0.8.13 && solc-select use 0.8.13
Installing solc '0.8.13'...
Version '0.8.13' installed.
Switched global version to 0.8.13

$ solc --optimize --ir-optimized src/A.sol | grep sstore
# (no match)

$ solc-select install 0.8.28 && solc-select use 0.8.28
Installing solc '0.8.28'...
Version '0.8.28' installed.
Switched global version to 0.8.28

$ solc --optimize --ir-optimized src/A.sol | grep sstore
# (no match)

Expected behavior: find sstore in the ir-optimized output.
Actual behavior: the sstore is missing from the ir-optimized output with solc 0.8.28.

It worked as expected in 0.8.12 but from 0.8.13 to 0.8.28, the sstore is missing from the ir-optimized output

@m4k2 m4k2 added the bug 🐛 label Jan 10, 2025
@m4k2 m4k2 changed the title Solidity Optimizer Bug (v0.8.13-0.8.28) Solidity optimizer bug (v0.8.13-0.8.28) Jan 10, 2025
@m4k2 m4k2 changed the title Solidity optimizer bug (v0.8.13-0.8.28) Optimizer bug (v0.8.13-0.8.28) Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant