Skip to content

unset() of a name that is later rebound by reference ($r = &$x[0]) does not release the value it held, so a reference inside it outlives the unset. #551

Open

Description

@blacktrs

Summary

unset() of a name that is later rebound by reference ($r = &$x[0]) does not release the value it held, so a reference inside it outlives the unset.

Repro

<?php
$a = [1, 2];
$r = [&$a[0]];
unset($r);
$b = $a;
$b[0] = 9;
echo $a[0], "\n";
$h = [1];
$r = &$h[0];

Expected (php)

1

Actual (manticore cc0bcfbe, Darwin arm64)

9

Tracking

Known-bug repro: tests/aot/repro/wrong/unset_reused_ref_name_keeps_value.php — bash tests/aot/xfail.sh -k unset_reused_ref_name_keeps_value reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Nov 2, 2026
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

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions