You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// SPDX-License-Identifier: MITcontractBugDetection {
uint256public storedValue;
uint8constant MAX_UINT8 =255;
function storeShiftedValue(uint256input) public {
// Inline assembly to manipulate bits directlyassembly {
let shifted :=shl(2, input) // Shift left by 2, may overflow if input is not managedsstore(storedValue.slot, shifted) // Store the shifted value to storedValue
}
storedValue =computeHashWithSideEffect(uint8(storedValue % (MAX_UINT8 +1)));
}
function computeHashWithSideEffect(uint8input) internalreturns (uint256) {
// Function with potential side-effect in the expressionuint8 interimValue = input;
bytes32 hash =keccak256(abi.encodePacked(interimValue +modifyState()));
returnuint256(hash);
}
function modifyState() internalreturns (uint8) {
storedValue = storedValue +1; // Intentional side-effect to modify statereturn1; // Return a small constant value
}
}
As in #15600, the fact that this runs into Unreported fatal error is a bug in itself, and needs a fix.
Here's the underlying error that triggers it:
Unreported fatal error:
/solidity/liblangutil/ErrorReporter.cpp(143): Throw in function void solidity::langutil::ErrorReporter::fatalError(solidity::langutil::ErrorId, solidity::langutil::Error::Type, const solidity::langutil::SourceLocation&, const std::string&)
Dynamic exception type: boost::wrapexcept<solidity::langutil::FatalError>
std::exception::what: Arithmetic error when computing constant value.
[solidity::util::tag_comment*] = Arithmetic error when computing constant value.
Internal compiler error:
/solidity/libsolidity/interface/CompilerStack.cpp(516): Throw in function bool solidity::frontend::CompilerStack::analyze()
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: Unreported fatal error.
[solidity::util::tag_comment*] = Unreported fatal error.
Minimized repro:
contractC {
uint8constant N =255;
function f() public {
N +1;
}
}
The underlying cause looks the same as in #15600 (i.e. #15709).
cameel
changed the title
SMTChecker:Internal compiler error
SMTChecker triggers an ICE by not reporting Arithmetic error when computing constant value fatal error caused by addition and type conversion of a constant
Jan 31, 2025
cameel
changed the title
SMTChecker triggers an ICE by not reporting Arithmetic error when computing constant value fatal error caused by addition and type conversion of a constant
SMTChecker triggers an ICE by not reporting Arithmetic error when computing constant value fatal error caused by constant addition
Jan 31, 2025
Environment
Steps to Reproduce
However, the program can be successfully compiled into bytecode.
The text was updated successfully, but these errors were encountered: