Skip to content

Stdlib: sprintf() missing %F conversion specifier (should match Zend) #9043

Description

@PurHur

Category

stdlib · php-src-strict

Problem

Zend supports %F in sprintf() / printf() / vsprintf() as a float conversion alias (uppercase f — same semantics as %f in practice for normal values).

This compiler throws at format-parse time:

LogicException: sprintf() unsupported conversion specifier %F in this compiler build

which breaks real-world format strings and parity with php-src.

php-src reference

Repro

# Zend reference
php -r 'echo sprintf("%F\n", 1.2);'

# VM failure today
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "echo sprintf(\"%F\\n\", 1.2);" 2>&1
php bin/vm.php -r "echo vsprintf(\"%F\\n\", [1.2]);" 2>&1
'

Zend expected: 1.200000 (representative; verify INF/NAN/-0.0 against Zend)
VM today: fatal LogicException before formatting.

Scope (this repo)

Path Role
ext/standard/VmSprintf.php add %F branch (likely alias to %f path)
ext/standard/sprintf.php, printf.php, vsprintf.php entry points
lib/JIT/Builtin/StringFormatJit.php if JIT parses specifiers separately, add %F there too
lib/JIT/Builtin/SscanfJit.php out of scope unless scanf gains F (not in php-src)

PHP-in-PHP first — implement in ext/standard + JIT PHP helpers; no runtime/*.c.

Done when

  • %F works on VM for sprintf / vsprintf / printf and matches Zend for: normal float, INF, NAN, -0.0
  • Unknown specifiers still raise ValueError: Unknown format specifier like Zend (not LogicException)
  • test/compliance/cases/stdlib/sprintf_F_specifier.phpt green
  • JIT/AOT format JIT path (if enabled) shares VmSprintf logic or documents VM-only gap

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions