argotorg / argotorg/solidity

msg.data, calldataload, calldatasize not available in constructor but no error in compiler

Open
#15,585 0 comments 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Description

constructor() is a different type of method, which dont have calldata.

When using msg.data on constructor, or equivalents in Yul, the result would be null. Although, no errors are presented by compiler.

```solidity
contract A {

event Log(bytes data, uint size);
bytes public b;
uint public size;
constructor (uint256 value)
{
uint s;
assembly {
s := calldatasize()
}
emit Log(msg.data, s);
b = msg.data;
size = s;
}
}

```
Logs:
```
[
{
"from": "0x8207D032322052AfB9Bf1463aF87fd0c0097EDDE",
"topic": "0x2c3af94f3304a9c884c0e74503327fb15ee45c874e155fd13b4d1f9ba9fb8857",
"event": "Log",
"args": {
"0": "0x",
"1": "0",
"data": "0x",
"size": "0"
}
}
]
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Solidity contract shown in the issue and inspect compiler handling of constructor context and the listed built-ins. The work is done when unsupported msg.data, calldataload, and calldatasize usage in constructors produces appropriate compiler errors, with tests covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.