AOT: integer overflow promotes to float on + and * (#31964) - #31980
Merged
Conversation
Zend promotes out-of-range long arithmetic to double; LLVM nsw add/mul was wrapping silently. Add JitLongArithOverflow shared by native-long and boxed numeric paths, with compile-time fold and compliance guards. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Aug 17, 2026
This was referenced Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib/JIT/JitLongArithOverflow.phpimplementing ZendZEND_SIGNED_ADD_OVERFLOW/ZEND_LONG_MUL_OVERFLOWfor JIT/AOT long arithmetic.Helper.phpand boxed numeric paths inJitValueNumeric.php..phptand targeted JIT/AOT PHPUnit guards.Closes #31964
php-src reference
Zend/zend_operators.h—ZEND_SIGNED_ADD_OVERFLOW,ZEND_LONG_MUL_OVERFLOWZend/zend_operators.c—add_function/mul_functionVerification
Not covered
7/2,$x++on float,%edge cases, cast-as-arg NULL) — separate causes, not changed here.Made with Cursor