digitalmars.D.bugs - [Issue 18854] New: std.allocator: StatsCollector counts failed
- d-bugmail puremagic.com (42/42) May 11 2018 https://issues.dlang.org/show_bug.cgi?id=18854
https://issues.dlang.org/show_bug.cgi?id=18854 Issue ID: 18854 Summary: std.allocator: StatsCollector counts failed deallocations Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: dlang-bugzilla thecybershadow.net ///////////////////////////// test.d ///////////////////////////// import std.exception : enforce; import std.experimental.allocator.building_blocks.region; import std.experimental.allocator.building_blocks.stats_collector; import std.experimental.allocator.gc_allocator; import std.typecons : Ternary; void main() { StatsCollector!(Region!GCAllocator, Options.bytesUsed) s; s.parent = Region!GCAllocator(1024); auto buf1 = s.allocate(100).enforce(); auto buf2 = s.allocate(100).enforce(); if (s.deallocate(buf1)) { // OK return; } else { // Oops, have to deallocate buf2 first s.deallocate(buf2).enforce(); s.deallocate(buf1).enforce(); // The region should be empty now, right? assert(s.empty != Ternary.no); // Nope! } } ////////////////////////////////////////////////////////////////// --
May 11 2018