[Issue 16508] Alignment of class members is not respected. Affects new, scoped and classInstanceAlignment.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 8 15:17:15 UTC 2021


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

--- Comment #5 from kinke <kinke at gmx.net> ---
(In reply to Max Samukha from comment #4)
> I'm curious why you chose to nitpick - it's unlikely you didn't understand
> what I meant.

Just stumbled upon this issue and wanted to correct this - `classInstanceSize`
doesn't need a fix.

> Class instance types exist implicitly and are commonly represented by
> structs.  The return type of std.typecons.scoped is an example, as you know.
> It is reasonable to expect arrays (and, in general, sequentially stored
> objects) of such structs to be usable.

A field like `align(C.alignof) void[__traits(classInstanceSize, C)] buffer`
should make sure there's appropriate padding, solely based on the align
declaration, which is required anyway and apparently does need fixing.

--


More information about the Digitalmars-d-bugs mailing list