Inconsistent defaults of `optimizeStackAllocation` flag cause ICEs and metadata issues in optimized compilation with Yul optimizer disabled
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
## 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
```solidity
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
```bash
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
```bash
solc --bin-runtime --optimize-yul --no-optimize-yul ./a.sol
```
and i get
```bash
Error: Options --optimize-yul and --no-optimize-yul cannot be used together.
```
this is consistent with the 1st point
and then i try command
```bash
solc --bin-runtime --optimize --no-optimize-yul ./a.sol
```
the compilation crashes at this time
```bash
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
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
Contributor guide
Assessment
This issue has not been assessed yet.