core.runtime.GC memory alignment

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Oct 27 13:30:57 PDT 2013


On 10/27/13 12:51 PM, Peter Alexander wrote:
> On Sunday, 27 October 2013 at 17:53:14 UTC, David Nadlinger wrote:
>> On Sunday, 27 October 2013 at 16:19:28 UTC, Peter Alexander wrote:
>>> "The malloc() and calloc() functions return a pointer to the
>>> allocated memory that is suitably aligned for any kind of variable."
>>>
>>> I see no reason to diverge from that.
>>
>> Welö, except for the fact that "any kind of variable" is not
>> well-defined for a language that supports user-defined alignment
>> restrictions:
>
> Correct me if I'm wrong, but my understanding is that align(N) on a
> member only specifies the alignment *within the struct*, i.e. the member
> offsets. There's no guarantee that the Foo object itself will be aligned
> to 8192. It's not really memory alignment.

Yah, something like that. I found align(NNN) underspecified and 
underpowered for my work with allocators. As a simple matter, NNN must 
be a literal, not a compile-time expression. You can't even write e.g. 
align(size_t.alignof), which is fairly basic.


Andrei



More information about the Digitalmars-d mailing list