Skip to content

Add #[no_drop_flag] attribute #7317

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

Closed
wants to merge 3 commits into from
Closed

Conversation

Aatch
Copy link
Contributor

@Aatch Aatch commented Jun 23, 2013

This adds a #[no_drop_flag] attribute. This attribute tells the compiler to omit the drop flag from the struct, if it has a destructor. When the destructor is run, instead of setting the drop flag, it instead zeroes-out the struct. This means the destructor can run multiple times and therefore it is up to the developer to use it safely.

The primary usage case for this is smart-pointer types like Rc<T> as the extra flag caused the struct to be 1 word larger because of alignment.

This closes #7271 and #7138

@Aatch
Copy link
Contributor Author

Aatch commented Jun 23, 2013

cc @thestinger

@brson
Copy link
Contributor

brson commented Jun 23, 2013

I guess this is fine but is there any plan to address this in a cleaner way? Under what situations will the dtor be called more than once?

Running dtors multiple times is pretty scary. I'm worried that aspect of this feature will be underappreciated since it isn't obvious or documented.

@thestinger
Copy link
Contributor

@brson: this is a stopgap until @pcwalton and @nikomatsakis implement the drop changes in the compiler, where drop flags won't be needed at all, assuming that works out

it needs to be updated to zero in the take glue instead of in the drop glue though for correctness

bors added a commit that referenced this pull request Jun 25, 2013
This adds a `#[no_drop_flag]` attribute. This attribute tells the compiler to omit the drop flag from the struct, if it has a destructor. When the destructor is run, instead of setting the drop flag, it instead zeroes-out the struct. This means the destructor can run multiple times and therefore it is up to the developer to use it safely.

The primary usage case for this is smart-pointer types like `Rc<T>` as the extra flag caused the struct to be 1 word larger because of alignment.

This closes #7271 and #7138
@bors bors closed this Jun 25, 2013
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.

AtomicOption is not pointer sized
4 participants