Skip to content

An array element that was once referenced keeps sharing its reference box after the reference is gone, so a copy of the array aliases the original. #548

Closed

Description

@blacktrs

Summary

An array element that was once referenced keeps sharing its reference box after the reference is gone, so a copy of the array aliases the original.

Repro

<?php
$a = [1, 2];
$r = [&$a[0]];
unset($r);
$b = $a;
$b[0] = 9;
echo $a[0], "\n";
function inc(&$x) { $x++; }
function f(array &$args) { inc(...$args); }
$c = [10];
f($c);
$d = $c;
$d[0] = 99;
echo $c[0], "\n";

Expected (php)

1
11

Actual (manticore c2b5d415, Darwin arm64)

9
99

Tracking

Known-bug repro: tests/aot/repro/wrong/ref_element_rc1_shared_on_copy.php — bash tests/aot/xfail.sh -k ref_element_rc1_shared_on_copy 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