Is it OK to use makeArray with ScopedAllocator to allocate something with a destructor?

Because the destructor is not called when ScopedAllocator goes out of scope. And if I manually call dispose, I get a double free error:

        struct A {
                int a;

                ~this() nothrow {
                }
        }
        void test(){
                import std.experimental.allocator.mallocator : Mallocator;
import std.experimental.allocator.building_blocks.scoped_allocator : ScopedAllocator;
                import std.experimental.allocator;
                ScopedAllocator!Mallocator alloc;

                auto b = alloc.makeArray!A(10, A(1));
                auto c = alloc.makeArray!A(2, A(2));


                alloc.dispose(b);
                alloc.dispose(c);

        }

        void main() {
                test();
        }

Reply via email to