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

Allocated ZSTs are immediately dropped #6

Closed
kstrafe opened this issue Apr 7, 2024 · 1 comment
Closed

Allocated ZSTs are immediately dropped #6

kstrafe opened this issue Apr 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@kstrafe
Copy link

kstrafe commented Apr 7, 2024

ZSTs should not be dropped as we may depend on their side-effects. Bumpalo does not drop ZSTs. If we add data to the type it is also not dropped.

use allocator_api2::alloc::Global;

type Bump = bump_scope::Bump<Global, 1, false>;
// type Bump = bumpalo::Bump;

#[test]
fn mytest() {
    struct DropEmit;
    impl Drop for DropEmit {
        fn drop(&mut self) {
            println!("=== DROPEMIT DROPPED === SHOULD NOT HAPPEN");
        }
    }

    let store = Bump::new();
    println!("Allocating");
    let dropemit = store.alloc(DropEmit);
    println!("Right after allocation");
    dropemit.into_raw();
}
@bluurryy bluurryy added the bug Something isn't working label Apr 7, 2024
@bluurryy
Copy link
Owner

bluurryy commented Apr 7, 2024

Thanks for filing this issue.

This is now fixed in version 0.1.6!

@bluurryy bluurryy closed this as completed Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants