Skip to content

Stdlib: preg_match()/preg_match_all() float $offset — LogicException not truncated int (ext/pcre/php_pcre.c) #13818

Closed

Description

@PurHur

Category

stdlib · php-src-strict · float→int coercion for PCRE search offset

Problem

Zend coerces float $offset to int for preg_match() / preg_match_all(). This compiler throws LogicException (preg_match() offset must be an integer in this compiler build) when $offset is a float such as 2.7.

php-src reference

Repro (verified 2026-06-29)

test/repro/maintainer_gap_preg_match_float_offset.php

php bin/vm.php test/repro/maintainer_gap_preg_match_float_offset.php
Check Zend VM
preg_match('/(l+)/','hello',$m,PREG_OFFSET_CAPTURE,2.7) → capture offset 2 LogicException

Apply same fix to preg_match_all().

Scope (PHP-in-PHP first)

Layer Path
VM ext/standard/preg_match.php, preg_match_all.php
JIT PCRE JIT builtins after VM green

Related: preg_split() float $limit tracked separately.

Done when (php-src-strict)

  • Repro exits 0 on VM
  • Float offset truncates like Zend for both match builtins
  • JIT/AOT agree when in scope

Verification

php bin/vm.php test/repro/maintainer_gap_preg_match_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 Compiler STD Lib — batch (issues #13883, #13884, #13818)

  3. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    Merged via #13892 — preg_match()/preg_match_all() coerce float offset via VmMath::parseIntBuiltinArgForFrame; JitLongArg fpToSi for JIT. VM repro + compliance 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