[Issue 16252] New: Region allocator should not be copyable
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jul 8 02:21:50 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16252
Issue ID: 16252
Summary: Region allocator should not be copyable
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: lodovico at giaretart.net
struct std.experimental.allocator.building_blocks.region.Region should have its
postblit disabled, at least when it has a non-empty destructor, i.e. when it
frees its store.
Consider the following code:
import std.experimental.allocator;
import std.experimental.allocator.mallocator;
import std.experimental.allocator.building_blocks.region;
import std.stdio: writeln;
void foo(Alloc)(Alloc alloc)
{
writeln("alloc disposed...");
}
void main()
{
auto alloc = Region!Mallocator(Mallocator.instance.allocate(128));
auto ptr = alloc.make!int(3);
writeln("*ptr = ", *ptr) // prints 3
foo(alloc);
writeln("*ptr = ", *ptr) // ops... invalid memory...
// ops... alloc destructor trying to free again the block already freed by
foo
}
--
More information about the Digitalmars-d-bugs
mailing list