Skip to content

Stdlib: unpack() float $offset under declare(strict_types=1) — silent truncate not TypeError (ext/standard/pack.c) #13862

Closed

Description

@PurHur

Category

stdlib · php-src-strict · binary unpack int $offset under caller strict_types

Problem

With declare(strict_types=1), Zend rejects float $offset to unpack() with TypeError. This compiler truncates and unpacks from the coerced int offset.

php-src reference

Repro (verified 2026-06-29)

test/repro/maintainer_gap_unpack_strict_float_offset.php

./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_unpack_strict_float_offset.php; php bin/vm.php test/repro/maintainer_gap_unpack_strict_float_offset.php'
Check Zend VM
unpack('c', "\x01", 1.9) under strict_types TypeError returns unpacked array (truncated offset)

Related: #11577 named format compile error; #4675 endian formats.

Scope (PHP-in-PHP first)

Layer Path
VM ext/standard/unpack.php
JIT pack/unpack lowering after VM green

Done when (php-src-strict)

  • Repro exits 0 on VM (TypeError)
  • Non-strict truncation unchanged
  • JIT agrees when in scope

Verification

php bin/vm.php test/repro/maintainer_gap_unpack_strict_float_offset.php

Links

Activity

  1. added
    enhancementNew feature or request
    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 29, 2026
  2. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (issues #13862, #13861, preloadLibcrypt dlopen follow-up #13858)

  3. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    Merged #13871 — unpack() float $offset TypeError under strict_types; Zend + VM repro green.

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 appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions