Skip to content

-mm=own: a global's value is lent to a call unless the call may assign that global - #678

Merged
ASDAlexander77 merged 1 commit into
mainfrom
own-global-arg-callee-assigns
Oct 23, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
own-global-arg-callee-assigns

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

What

Under -mm=own, a value read out of an assigned global can now be lent to a call unless the call may assign that global, or a global the pass cannot name.

Why

#639 refused any call that might drop anything once it was lent such a value. Only a store to the global releases its block, so G = new N(2); other(G), where other assigns a different global H, was rejected (the "#639 is coarse" half of own-raytrace follow-up 14).

rejectGlobalArgumentsDropped now reads __own_assigns_globals / __own_assigns_any_global. pinAssignedGlobals (#661) puts these on each call and runs just before the check. A callee that assigns the global itself, through another function, through a method or through a function value is still refused (new negative own_err_global_argument_indirect; the existing transitive and method negatives still pass).

own_err_global_kept_field is now refused by checkGlobalRead, the check that test was written for: keep stores the lent value into a field that outlives the next assignment of g. The test's comment and pinned message are updated to match.

Tests

  • own_global_argument_other_global covers a callee, and a callee's callee, that assign another global. It runs under own, rc, gc and none.
  • Full suite: Windows 5465 and Linux 5444, where the only failure was the old pin above. With the new pin, all 41 related tests pass on both systems; neither full suite was rerun after that.
  • Own corpus on Linux: unchanged at 533, nothing lost.

🤖 Generated with Claude Code

…n that global

#639 refused any call that might drop anything once a value read out of an
assigned global was lent to it, though only a store to the global releases its
block: `G = new N(2); other(G)`, where other assigns H, was rejected. The check
now reads what pinAssignedGlobals (#661) put on the call, which runs before it:
it refuses a call that may assign that global, or one it cannot name (an
indirect call, a callee calling one), and lends to any other. A callee that
assigns the global itself, through another function, a method or a function
value is still refused.

own_err_global_kept_field is now refused by checkGlobalRead, which it was
written for: `keep` stores the lent value into a field that outlives the next
assignment of `g`; its pinned message follows. Tests: own_global_argument_other_global
under every model, own_err_global_argument_indirect. Own corpus unchanged (533).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 0f0f283 into main Oct 23, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-global-arg-callee-assigns branch October 23, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant