Bug 1836 – Inline assembler can't use enum values as parameters.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2008-02-14T14:41:00Z
Last change time
2014-02-24T15:33:33Z
Assigned to
bugzilla
Creator
burton-radons

Comments

Comment #0 by burton-radons — 2008-02-14T14:41:46Z
The inline assembler rejects any attempt to use an enum value as a parameter: enum { enumeration = 1, } void test () { asm { mov EAX, enumeration; } } This code fails compilation with "bad type/size of operands 'enumeration'", regardless of whether enum is given a type or if AX or AH is attempted instead. It should be equivalent to "mov EAX, 1;". The workaround is to assign the enumeration value to a const value before the asm statement.
Comment #1 by thomas-dloop — 2008-02-25T05:07:44Z
Comment #2 by burton-radons — 2008-02-25T13:00:43Z
Did you intend for B-D to succeed in the current compiler, Thomas? Because you assign "const dummy = enumeration;" in them but you continue to use "enumeration" in the asm code.
Comment #3 by bugzilla — 2008-03-07T00:30:20Z
Fixed dmd 1.028 and 2.012