This works fine:
align(16) int x;
This doesn't:
enum alignment = 16;
align(alignment) int x;
Or any other expression for that matter. Can't do:
align(T.alignof) int x;
This makes some generic code impossible.
Comment #1 by samukha — 2013-05-23T09:49:49Z
dmd has quite a few bugs like that. Your case should be easy to workaround with a string mixin. Something like:
enum alignment = 16;
mixin("align(" ~ to!string(alignment) ~") int x;");
// or
mixin(format("align(%s) int x;", T.alignof));
Comment #2 by bearophile_hugs — 2013-05-23T09:58:15Z
*** This issue has been marked as a duplicate of issue 9766 ***