argotorg / argotorg/solidity

Assigning the selector of a parent function to a constant crashes solc

Open
#16,050 0 comments 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

This Solidity:

```Solidity
contract B {
function g() public {}
}

contract C is B {
// the constant keyword triggers the crash
bytes4 public constant s2 = B.g.selector;
}
```

crashes the compiler with the following error:

```
❯ solc --version
solc, the solidity compiler commandline interface
Version: 0.8.30+commit.73712a01.Linux.g++
❯ solc --ir reproducer.sol
Uncaught exception:
Dynamic exception type: std::out_of_range
std::exception::what: map::at
```

Contributor guide

Open the contributing guide

Research direction

Start by compiling the supplied reproducer with solc 0.8.30 and the --ir option, confirming the std::out_of_range map::at crash. Trace the compiler path handling a parent function selector in a constant initializer; done means the example compiles without crashing and has a regression test covering this case.

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
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.