Bug 18877 – std.allocator: RCIAllocator's .alignment() method is not readable at compile-time

Status
NEW
Severity
minor
Priority
P5
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-19T17:27:04Z
Last change time
2024-12-01T16:33:48Z
Assigned to
No Owner
Creator
Vladimir Panteleev
Moved to GitHub: phobos#9759 →

Attachments

IDFilenameSummaryContent-TypeSize
1696alignment-1.patchDraft patch for making alignment a methodtext/plain3256

Comments

Comment #0 by dlang-bugzilla — 2018-05-19T17:27:04Z
Created attachment 1696 Draft patch for making alignment a method Many building block allocators have a line such as: enum uint alignment = Allocator.alignment; or: alias alignment = ParentAllocator.alignment; This doesn't work when the parent allocator is an opaque class. Possible solutions: - Forego use of alignment as a compile-time value, instead treating it as a runtime value everywhere. Rely on compiler optimizations to punch through the layers as needed. This is probably not feasible as many allocators rely on the underlying types having a predefined, constant alignment. Using ParentAllocator.init.alignment allows hacking around this, though. Attached is a draft patch towards this approach. - Declare alignment as an enum/alias iff ParentAllocator's alignment can be read at compile-time. For allocators that require knowing the alignment beforehand, this can be made as an explicit check (to produce a human-readable error message if they are used with e.g. RCIAllocator).
Comment #1 by robert.schadek — 2024-12-01T16:33:48Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9759 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB