www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16253] New: BitmappedBlock allocator not working with

https://issues.dlang.org/show_bug.cgi?id=16253

          Issue ID: 16253
           Summary: BitmappedBlock allocator not working with
                    chooseAtRuntime
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: lodovico giaretart.net

This simple code does not compile:

import std.stdio;
import std.experimental.allocator;
import std.experimental.allocator.common;
import std.experimental.allocator.building_blocks.bitmapped_block;

void main()
{
    auto alloc = BitmappedBlock!chooseAtRuntime(new void[1024]);
    writeln(alloc.blockSize);
}

Error: template instance
std.experimental.allocator.building_blocks.bitmapped_block.BitmappedBlock!(18446744073709551614LU,
16u, NullAllocator) error instantiating

This instantiation error looks like an easily fixeable bug.
The real problem is that, if I understand correctly, BitmappedBlock, in its
current form, will *never* work with chooseAtRuntime, because the constructors
need to know the blockSize, and there's no way to set it at runtime before the
constructor is executed.
The documentation explicitly says that with chooseAtRuntime the blockSize shall
be passed to the constructor, but no constructor takes it (one takes a void[]
block and the other the total memory size requested).

--
Jul 08 2016