Skip to content

Regression: bindec()/hexdec()/octdec(null) still coerce under PROFILE=8.4 (ext/standard/math.c) #20658

Description

@PurHur

Category

stdlib · php-src-strict · PHP 8.4 null→TypeError (Z_PARAM_STR)

Problem

php-src bindec/hexdec/octdec parse with Z_PARAM_STR. On PHP 8.4, null must raise TypeError, not coerce to \"\" / return 0. Under PHP_COMPILER_PROFILE=8.4 this compiler still coerces (via VmString::stringBuiltinArgForFrame → coerceStringBuiltinArg, where requiresForwardProfileStrictStringNull() is false). Sibling converters decbin/dechex/decoct already TypeError on null.

Repro php-src 8.4 (Z_PARAM_STR) VM (2026-07-18)
bindec(null) TypeError 0 (coerce)
hexdec(null) TypeError 0 (coerce)
octdec(null) TypeError 0 (coerce)

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro/issue_NNNNN_bindec_hexdec_octdec_null.php'

Minimal script:

<?php
foreach ([\"bindec\",\"hexdec\",\"octdec\"] as $f) {
  try { var_export($f(null)); echo \" $f=COERCE\n\"; }
  catch (TypeError $e) { echo \"$f=TYPEERROR\n\"; }
}

Done when

  • PHP_COMPILER_PROFILE=8.4: bindec/hexdec/octdec(null) → TypeError on VM + JIT/AOT
  • Compliance .phpt under test/compliance/cases/ (or extend existing math null suite)
  • php-src-strict; no php-compiler-strict shortcut
  • Default/8.2 profile may keep deprecation+coerce if that matches Zend 8.2

Refs: pillar 4 on #10533; related trim/strlen batch #20635 (different builtins).

Activity

  1. added
    bugSomething isn't working
    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 Jul 18, 2026
  2. PurHur commented on Jul 18, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

    Pillar 1: inventory OK; user_release_ready: yes; bootstrap-selfhost-link OK.

    Repro: PHP_COMPILER_PROFILE=8.4 → bindec/hexdec/octdec(null) still coerce to 0; siblings using coerceZparamStrBuiltinArg already TypeError.

    Switching these to Z_PARAM_STR forward-profile guards (php-src ext/standard/math.c); keep 8.2 coerce+deprecate.

  3. PurHur commented on Jul 18, 2026

    @PurHur
    OwnerAuthor

    Merged via #20713

    Verification:

    • VM/JIT PROFILE=8.4: bindec/hexdec/octdec(null) → TypeError
    • VM PROFILE=8.2: still coerces to 0
    • AOT: bindec(null) binary exits 255 with TypeError (bindec_null_forward84 AotTest OK)
    • phpunit --filter bindec_hexdec_octdec_null OK (3)

    php-src: ext/standard/math.c Z_PARAM_STR; PHP impl: ext/standard/{bindec,hexdec,octdec}.php + JitStringBuiltinArg::lowerZparamStr.

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 machinebugSomething isn't workingimplementation-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