Bug 1614 – sizeof Gives Error When Used Inside an Inline Assembly Block
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2007-10-26T10:53:00Z
Last change time
2015-06-09T01:14:21Z
Assigned to
bugzilla
Creator
johnkirollos
Comments
Comment #0 by johnkirollos — 2007-10-26T10:53:15Z
Statement like "mov ECX,float.sizeof;" is not accepted by the compiler: Error: "ptr expected".
Consider the following example (same example used also in issue # 1500):
========================================
void asm_template(T)(T Tval,T* pDest)
{
asm{
fld Tval;
mov EAX,pDest;
fstp T ptr[EAX]; //#1
fstp float ptr[EAX]; //#2
mov EDX,T.sizeof; //#3 (this statement is ok!)
mov ECX,float.sizeof; //#4 (ERROR: "ptr expected")
}//asm
}//asm_template
void main()
{
float f1=4.0;
float f2=5.0;
asm_template!(float)(f1,&f2);
}
========================================
Here is the compilation result of the 4 statements marked above:
#1: ERROR: "cannot use type float as an operand" (issue # 1500)
#2: OK
#3: OK!!!
#4: ERROR: "ptr expected" (this issue)
Normally statement # 4 should be accepted, as 'float.sizeof' should be translated into the value '4'.
Workaround:
alias float.sizeof FLOAT_SIZE;
...
mov EAX,FLOAT_SIZE;
Comment #1 by matti.niemenmaa+dbugzilla — 2007-10-26T13:10:55Z
*** This bug has been marked as a duplicate of 1252 ***