Skip to content

php-in-php: fpow() early registration — align #4605 with VmMath, version gate, and IEEE edge cases #7045

Description

@PurHur

Category

stdlib | php-in-PHP

Problem

#4605 was filed when fpow() was entirely missing. Audit (2026-06-06): VM now registers fpow() (function_exists('fpow') → true, fpow(2,3)8) while the open issue still describes undefined-function failure.

Remaining gaps vs php-src ext/standard/math.c PHP_FUNCTION(fpow):

  1. Version gate — exposed on CompilerVersion 8.3.0-dev before PHP 8.4 target alignment
  2. IEEE edge casesfpow(-1, 0.5)NAN, fpow(0, -1)INF, signed-zero exponent rules
  3. TypeError paths — non-numeric operands (Z_PARAM_DOUBLE), enum case operands (php-src-strict)
  4. JIT/AOT — may still defer; capability matrix must reflect reality
  5. Implementation location — ensure logic lives in ext/standard/VmMath.php / fpow.php, not ad-hoc C

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_export(function_exists(\"fpow\")); echo PHP_EOL; var_export(fpow(2,3)); echo PHP_EOL; var_export(fpow(-1,0.5)); echo PHP_EOL;"
php -r "var_export(function_exists(\"fpow\")); echo PHP_EOL;" 2>/dev/null || echo zend_pre_84
'
Check Expected (Zend 8.4+) VM today
function_exists('fpow') true (8.4+) true (early)
fpow(2,3) 8.0 8
fpow(-1,0.5) NAN verify ❓
Enum case arg TypeError verify ❓

Scope

Path Work
ext/standard/fpow.php / VmMath.php centralize libc pow() + edge cases
lib/CompilerVersion.php supportsFpow() ≥ 8.4
lib/JIT/ native double pow lowering (phase 2)
#4605 close or rewrite when this lands
Tests test/compliance/cases/stdlib/fpow*.phpt

No new runtime/*.c math helpers.

Done when

  • Behavior matrix matches Zend 8.4 for happy + edge cases
  • CompilerVersion gate prevents fpow on pre-8.4 target if required by project policy
  • php-src-strict enum/object operand rejection on VM (+ JIT when lowered)
  • Stdlib: fpow() — IEEE-754 exponentiation (ext/standard/math.c, PHP 8.4) #4605 updated/closed; capability matrix row accurate (VM yes / JIT status)
  • ./script/ci-fast.sh --filter fpow green

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:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions