Bug 10149 – align() expects integer literal

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-23T04:39:00Z
Last change time
2013-05-23T09:58:15Z
Assigned to
nobody
Creator
turkeyman

Comments

Comment #0 by turkeyman — 2013-05-23T04:39:11Z
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 ***