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

never construct value on stack in new_box_zeroed (#1601) #1604

Open
wants to merge 1 commit into
base: v0.7.x
Choose a base branch
from

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Sep 3, 2024

On lower opt-levels the compiler might not optimize out the layout.size() == 0 branch and emits code for the if-body. This will cause a stack allocation for Self. Avoid calling new_zeroed() and directly construct the Box from a dangling pointer instead.

On lower opt-levels the compiler might not optimize out the
`layout.size() == 0` branch and emits code for the if-body. This will
cause a stack allocation for `Self`. Avoid calling new_zeroed() and
directly construct the Box from a dangling pointer instead.

Co-authored-by: Joshua Liebow-Feeser <[email protected]>
@joshlf joshlf mentioned this pull request Sep 3, 2024
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.

3 participants