Skip to content

(array) of a string|array parameter stores the argument without retaining it: a fresh string argument is freed and reused #181

Closed

Description

@blacktrs

Summary

(array) of a string|array parameter stores the argument without retaining it: a fresh string argument is freed and reused.

Repro

<?php
class L
{
    protected array $paths;
    public function __construct(string|array $p = [])
    {
        $this->paths = (array) $p;
    }
    public function first(): string { return $this->paths[0]; }
}

function mk(string|array $p = []): L { return new L($p); }

$base = '/tmp/some/dir/' . strlen('abc');
$l = mk(\dirname($base . '/x'));
$noise = [];
for ($i = 0; $i < 5; $i++) { $noise[] = str_repeat('n', 12) . $i; }
echo $l->first(), "\n";

Expected (php)

/tmp/some/dir/3

Actual (manticore 032e761a, Darwin arm64)

nnnnnnnnnnnn

Tracking

Known-bug repro: tests/aot/repro/wrong/array_cast_of_union_string_param_dangles.php — bash tests/aot/xfail.sh -k array_cast_of_union_string_param_dangles 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 Oct 11, 2026
  2. added a commit that references this issue on Oct 14, 2026
    72dc880
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