Perf: printf/sprintf %d of floats and overflow longs match Zend (#36386) - #37075
Merged
Conversation
Integer conversions were passing i64 to libc %d (LP64 reads 32-bit → PHP_INT_MIN printed 0) and IEEE doubles without zend_dval_to_lval. Promote %d→%lld, coerce floats via saturating dval_to_lval, and teach packed argv TAG_DOUBLE → (int). Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Sep 6, 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
printf/sprintf%d/%u/%xof overflow-promoted ints and large floats printed0(or garbage) while%s/echo/%gmatched Zend — leftover of Perf: lazy f64 overflow slot for native-long ±/× (#36386) #37051 lazy ±/× materialize and LP64 libc%dreading 32-bit ints from i64 varargs.%lld/%llu/%llx, coerce floats via saturatingzend_dval_to_lval(JitLongArg::doubleToZendLong), and accept packed argvTAG_DOUBLEas(int)inSprintfJitHelper.php-src:
ext/standard/formatted_print.cphp_formatted_print/zval_get_long;Zend/zend_operators.hzend_dval_to_lval.Test plan
./script/phpunit.sh --filter 'SprintfPercentDFloatAotTest|SprintfOverflowableNativeLongAotTest|EchoOverflowableNativeLongAotTest'→ 13/13 OK./script/aot-smoke.sh→ 9/9 + size gate OKmake north-star5-verify-fast→ OK (spine 8351/8351)script/differential-sweep.sh --aot --repeat 3(sprintf coercion only; peer of Perf: printf/sprintf %s of overflowable native-long matches Zend (#36386) #37068)Closes nothing (Part of #36386).
Made with Cursor