Skip to content

Inconsistent defaults of optimizeStackAllocation flag cause ICEs and metadata issues in optimized compilation with Yul optimizer disabled #15641

Open
@P1umH0

Description

@P1umH0

Environment

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

Steps to Reproduce

A fairly simple code named a.sol

contract SimpleContract {
    uint256 public value;
    constructor(uint256 _initialValue) {
        value = _initialValue;
    }
    function setValue(uint256 _newValue) public {
        value = _newValue;
    }
    function getValue() public view returns (uint256) {
        return value;
    }
}

The help message shows two points:

  1. options "--optimize-yul" and "--no-optimize-yul" are contradictory
  2. if "--optimize" is enabled, "--optimize-yul" will be enabled automatically
Optimizer Options:
  --optimize           Enable optimizer.
  --optimize-runs n (=200)
                       The number of runs specifies roughly how often each 
                       opcode of the deployed code will be executed across the 
                       lifetime of the contract. Lower values will optimize 
                       more for initial deployment cost, higher values will 
                       optimize more for high-frequency usage.
  --optimize-yul       Enable Yul optimizer (independently of the EVM assembly 
                       optimizer). The general --optimize option automatically 
                       enables this unless --no-optimize-yul is specified.
  --no-optimize-yul    Disable Yul optimizer (independently of the EVM assembly
                       optimizer).
  --yul-optimizations steps
                       Forces Yul optimizer to use the specified sequence of 
                       optimization steps instead of the built-in one.

I try command

solc --bin-runtime --optimize-yul --no-optimize-yul ./a.sol

and i get

Error: Options --optimize-yul and --no-optimize-yul cannot be used together.

this is consistent with the 1st point
and then i try command

solc --bin-runtime --optimize --no-optimize-yul ./a.sol

the compilation crashes at this time

Internal compiler error:
/solidity/libsolidity/interface/CompilerStack.cpp(1719): Throw in function std::string solidity::frontend::CompilerStack::createMetadata(const solidity::frontend::CompilerStack::Contract&, bool) const
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: Solidity assertion failed
[solidity::util::tag_comment*] = Solidity assertion failed

According to the 2nd point, I should get the same or similar error as before, but here it crashes for some reason

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛low effortThere is not much implementation work to be done. The task is very easy or tiny.medium impactDefault level of impact

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions