ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
22.66k stars 5.62k forks source link

Comparing function pointers may yield unpredictable results #15129

Closed yantao0527 closed 1 month ago

yantao0527 commented 1 month ago

Description

Comparing function pointers may yield unpredictable results due to potential differences in the address space layout of functions across program executions

Environment

Steps to Reproduce

contract C {
    function f() internal {}
    function g() internal {}

    function test() public pure returns (bool) {
        return C.f == C.g;
    }
}
r0qs commented 1 month ago

Hi, this is a duplicate of https://github.com/ethereum/solidity/issues/13969 and since Solidity version 0.8.24 the compiler issue a warning about it.