Skip to content

Stdlib: nextafter() missing — IEEE next representable float (ext/standard/math.c) #9241

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

nextafter(float $num, float $next) is part of ext/standard math in php-src (PHP 8.4+). This compiler has no builtin — function_exists('nextafter') is false and calls fatal as undefined.

php-src reference

Repro

<?php
declare(strict_types=1);
var_dump(function_exists('nextafter'));
var_export(nextafter(1.0, 2.0));
echo "\n";
var_export(nextafter(1.0, 0.0));
echo "\n";
./script/docker-exec.sh -- bash -lc 'php repro_nextafter.php
php bin/vm.php repro_nextafter.php'
Engine Result
Zend PHP 8.4+ bool(true) + IEEE next representable floats toward $next
This compiler VM bool(false) + Call to undefined function nextafter()

Scope (PHP-in-PHP)

Layer Path
VM ext/standard/nextafter.php (new), delegate to VmMath / ext/standard/VmMath.php
Registry ext/standard/ModuleRegistry.php, Module.php
JIT ext/standard/JitMath.php or reuse float builtin lowering — match VM
Tests test/compliance/cases/ext/nextafter.phpt

Implement with platform nextafter(3) only behind thin FFI if needed; prefer PHP VmMath wrapper calling libc via existing native helper patterns (VmMathNative).

Done when (php-src-strict)

  • Repro prints true + same floats as Zend for toward +inf and toward 0.0
  • Non-float operands raise same TypeError as Zend
  • JIT/AOT agree with VM (or follow-up JIT issue filed with link)
  • docs/capabilities.md regenerated via php script/capability-matrix.php
  • ./script/ci-fast.sh --filter nextafter green

Related

Activity

  1. added
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 17, 2026
  2. PurHur commented on Jul 2, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #9241, #9991)

  3. PurHur commented on Jul 2, 2026

    @PurHur
    OwnerAuthor

    Merged via PR #15017. VmMath::nextafter polyfill + PHP 8.4+ gated registration; repro skips on 8.4.0-dev reference profile as expected.

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 machineimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions