[Issue 9766] align(n) with n compile-time constant
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Aug 8 07:19:09 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=9766
Leandro Lucarella <leandro.lucarella at sociomantic.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|rejects-valid |industry, spec
CC| |leandro.lucarella at sociomant
| |ic.com
--- Comment #2 from Leandro Lucarella <leandro.lucarella at sociomantic.com> ---
Removed reject-invalid keyword as the specification indicates the syntax is:
align ( IntegerLiteral )
In Sociomantic, being able to specify a compile-time calculated value to align
would be useful to overcome alignment issues with structs with static arrays in
them. For example:
---
struct E1
{
byte key;
ubyte[(char[]).sizeof] val;
}
---
E1.key offset: 0LU, E1.val offset: 1LU
This is very impolite to the GC. Trying the same in C, it works the same, and
since D defines his alignment specification in terms of the host C compiler,
this is technically not a bug but a feature. But a better way to overcome this
than manually adding padding bytes between both members would be appreciated
(using align(8) is not portable, and starting a version() madness because of
this doesn't seem like a good option).
--
More information about the Digitalmars-d-bugs
mailing list