Skip to content

Fix negative zero from I256 sdiv/srem with mixed-sign operands - #302

Merged
sbillig merged 1 commit into
fe-lang:mainfrom
SAY-5:fix-sdiv-negative-zero
Jul 30, 2026
Merged

Fix negative zero from I256 sdiv/srem with mixed-sign operands#302
sbillig merged 1 commit into
fe-lang:mainfrom
SAY-5:fix-sdiv-negative-zero

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

When sdiv/srem operands have different signs and the result is zero, overflowing_div/overflowing_rem built I256 { is_negative: true, abs: 0 }, and hashing that value overflows in to_u256 (!0 + 1), which panics SCCP when it folds e.g. evm_sdiv(-1, 5). Fixes #300 by canonicalizing zero in make_negative.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>

@sbillig sbillig left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SAY-5 Thank you! This looks correct. Sorry for the delay, I just noticed this pr.

@sbillig
sbillig merged commit 8e6c99f into fe-lang:main Jul 30, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal compiler crash when SCCP folds evm_sdiv to negative zero

2 participants