solidity icon indicating copy to clipboard operation
solidity copied to clipboard

IR-based Codegen fails to compile at version of 0.8.13

Open Subway2023 opened this issue 10 months ago • 0 comments

Description

When I try to reproduce this bug DataLocationChangeInInternalOverride I find that IR-based Codegen fails to compile at version of 0.8.13.

Environment

  • Compiler version: 0.8.13
  • Target EVM version (as per compiler settings): No restrictions
  • Framework/IDE (e.g. Truffle or Remix): Command-line
  • EVM execution environment / backend / blockchain client: None
  • Operating system: Linux

Steps to Reproduce

abstract contract I {
    // The base contract uses "calldata"
    function f(uint[] calldata x) virtual internal;
}
contract C is I {
    // The derived contract uses "memory" and the compiler
    // does not complain - this is the bug in the compiler.
    function f(uint[] memory x)  override internal {
        // If you use `x`, it will access memory
        // even if `D.g` passed us a calldata pointer.
        // This leads to the wrong data being accessed.
    }
}
abstract contract D is I {
    function g(uint[] calldata x)  external {
        // Since D only "knows" `I`, the signature of `f`
        // uses calldata, while the virtual lookup ends
        // up with `C.f`, which uses memory. This results
        // in the calldata pointer `x` being passed and
        // interpreted as a memory pointer.
        f(x);
    }
}
contract X is C, D { }
solc-0813 test.sol --via-ir
1713706385207

Subway2023 avatar Apr 21 '24 13:04 Subway2023