Comments (6)
Thanks for the report! It's a real issue, but we already have one covering it (#13969), so I'm going to close this one as a duplicate.
On 0.8.x and earlier it's best to consider the result of comparisons between internal function pointers undefined (i.e. it has a consistent value, but not across compilations; do not rely on this value staying the same regardless of compiler settings or releases). The pointer type has always been (intentionally) treated as opaque in the language. The underlying value cannot be obtained without using assembly and was only indirectly exposed via this kind of comparison. Its usefulness is questionable so hopefully this pattern is pretty rare. A proper fix is breaking so it's only going to be fixed in 0.9, but we're going to start issuing a warning about this pattern soon.
solc compiler ignored the effect of identifiers on the contract code when the optimizer was on, only cared about the function statements, and collapsed the storage if the function statements were consistent.
Well, the values of the storage variables are never used (statements a;
and b;
have no side-effects) so the optimizer is very likely to remove them and collapse the function bodies into one.
from solidity.
But I ran into the same problem in a similar example below:I can understand that when f3() is executed, the local variable has been released, so the optimizer considers it consistent.
pragma solidity ^0.8.18;
contract Test {
function c() public {uint a = 1;}
function b() public {bool a = true;}
function f3() external returns(bool) {
return c == b;
}
}
from solidity.
hello,I was wondering if you could still receive my comments after the issue is closed?
from solidity.
I mean, this issue is closed as a duplicate, but #13969 is still open. But I'm not sure what your question is here.
from solidity.
What I mean is that the original examples provided may not have significant functional differences, but in the following examples, the local variable "uint a = 1;" and "bool a = true;" should not generate the same error. However, in fact, they triggered the aforementioned error.
contract Test {
function c() public { uint a = 1;}
function b() public { bool a = true;}
function f3() external returns(bool) {
return c == b;
}
}
from solidity.
Why do you think they should not generate the same error? Both variable declarations are basically no-ops so the optimizer may remove them.
If you want something that won't get optimized out, it needs to affect the environment. Like, change the return value, write to storage, emit an event, revert, etc.
BTW, if you want to see what really happens, compile with --optimize --ir-optimized
and look for the function in the output.
from solidity.
Related Issues (20)
- replace `Brownie` with `Ape` HOT 8
- Incorrect `parameterSlots` and `returnSlots` for some methods in `functionDebugData`
- Stack too deep errors with via-IR for some compilation routines
- Enable function overloading resolution when importing specific libraries or free functions via `using for` HOT 1
- `StackCompressor` goes into infinite loop after `SSATransform` on inline assembly with very long chains of dependent assignments HOT 2
- Add blobhash inside the `tx` context: blobhash(uint index) --> tx.blobhash(uint index) HOT 4
- SMTChecker: Use SMT-LIB interface instead of solvers' APIs
- Lack of proper heuristics in the Function Specializer can lead to large contract sizes HOT 5
- build solidity error HOT 3
- When compiling with the `via-ir` option, calldata out-of-bounds causes the transaction to revert HOT 1
- Support for Compiling Solidity to LLVM IR to Facilitate zkVM Adoption?
- Switch default EVM version to Cancun
- Performance issues of `solc --abi --via-ir` HOT 6
- Verifying blobhash causes failure to obtain gasLimit HOT 2
- Security vulnerability: Why do % and MOD result in different outputs despite being technically the same function? HOT 2
- SMT logic error for a conditional with empty tuple types
- Code Deduplication Creates Wrong Source Mappings
- `memory-safe` Assembly Worsens Optimizations HOT 2
- Reduce default font weight for readability HOT 2
- Providing an empty string to `--yul-optimizations` without enabling yul optimization triggers uncaught exception HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solidity.