Skip to content

std.experimental.allocator.make doesn't even try to respect class alignment #10847

@ichordev

Description

@ichordev

The following code triggers an assert in core.lifetime.emplace due to the allocated pointer for S not being aligned to __traits(classInstanceAlignment, S):

class S{}

void main(){
	import std.experimental.allocator: make;
	import std.experimental.allocator.building_blocks: BitmappedBlock;
	auto alloc = BitmappedBlock!(17,1)(new ubyte[](64));
	auto a = make!S(alloc);
	auto b = make!S(alloc); //core.exception.AssertError@/dlang/ldc-1.41.0/bin/../import/core/lifetime.d(207): chunk is not aligned.
}

BitmappedBlock implements alignedAllocate, which make could use to trivially avoid this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions