Category
stdlib · compile lowering · php-src-strict
Problem
vsprintf('%d', [7]) fails at runtime when the second argument is an inline array literal, while the same values in a variable work. Zend returns the formatted string.
| Call |
Zend |
VM today |
vsprintf('%d', [7]) |
'7' |
LogicException: second argument must be an array |
$a=[7]; vsprintf('%d',$a) |
'7' |
'7' (OK) |
Same class of bug as literal-null / inline-[] mis-binding (#9305, #9563, #9349).
php-src reference
Repro
php test/repro/maintainer_vsprintf_inline_array.php
php bin/vm.php test/repro/maintainer_vsprintf_inline_array.php
php bin/vm.php -r '\$a=[7]; echo vsprintf("%d", \$a);' # control: OK
Scope (PHP-in-PHP)
- Fix builtin argument marshalling for inline array literals in
lib/ compiler / VM call path
ext/standard sprintf family if argc guards assume non-literal arrays
Done when (php-src-strict)
Links
Category
stdlib· compile lowering · php-src-strictProblem
vsprintf('%d', [7])fails at runtime when the second argument is an inline array literal, while the same values in a variable work. Zend returns the formatted string.vsprintf('%d', [7])'7'$a=[7]; vsprintf('%d',$a)'7''7'(OK)Same class of bug as literal-null / inline-
[]mis-binding (#9305, #9563, #9349).php-src reference
ext/standard/sprintf.c—PHP_FUNCTION(vsprintf)ext/standard/tests/strings/vsprintf*.phptRepro
Scope (PHP-in-PHP)
lib/compiler / VM call pathext/standardsprintf family if argc guards assume non-literal arraysDone when (php-src-strict)
7on VMLinks