Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Box(T).box allocates when T < Pointer #15562

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ysbaddaden
Copy link
Contributor

@ysbaddaden ysbaddaden commented Mar 17, 2025

While discussing to use Box(T) in #15395 I noticed that Box(Pointer).box(ptr) allocates into the GC heap to store the pointer address into.

That felt like an overlook since we don't need to allocate to box a Reference or Nil, so it should be fine to box a raw pointer without allocating an intermediary pointer. Am I missing something?

I only allowed T < Pointer in addition to the Reference and nilable Reference cases. I'm not sure a Pointer appearing in an union along Nil or Reference would behave correctly —is it passing the {type, value} union by value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants